creating a pdf version of a complicated form, populated with data from a database
karl at aspodata.se
karl at aspodata.se
Fri Apr 5 15:08:54 CEST 2024
Karl:
> Chris:
> > I dream of using R, Rmarkdown, knittr, and pdflatex to pull individual
> > records from a database and generate a form like page 1 here:
> >
> > https://www.cigna.com/static/www-cigna-com/docs/form-cms1500.pdf
PostScript example follows:
$ pdfimages form-cms1500.pdf a
$ pnmtops -imagewidth=8.5 a-0000.ppm > form-cms1500.eps
pnmtops: generating color Postscript program.
$ cat pre.ps form-cms1500.eps end.ps > tt.ps
$ gv -watch -scale=4 tt.ps
You can use gv to find coordinates of where to place your text,
they are shown in gv top-left. To the left, under som buttons,
there is a "greyer" area with a light gray rectangle in it.
Press left mouse button in the ligth gray area and move to move
around on the page.
The pre.ps and end.ps files as below.
If you want pdf files instead, do:
ps2pdf tt.ps
For information about postscript, search for adobes PLRM2.pdf or PLRM3.pdf
=========== pre.ps, mostly from appendix H.7 "EPS Example" PLRM2.pdf
%!PS-Adobe-3.0
%%BoundingBox: 0 0 612 792
%%Creator: form-cms1500-generator
%%Title: (form-cms1500)
%%CreationDate: 05/04/24 (14:16)
%%Pages: 1
%%DocumentFonts: Helvetica Times-Italic
%%DocumentNeededFonts: Helvetica Times-Italic
%%EndComments
%%BeginProlog
/BeginEPSF { %def
/b4_Inc_state save def % Save state for cleanup
/dict_count countdictstack def % Count objects on dict stack
/op_count count 1 sub def % Count objects on operand stack
userdict begin % Push userdict on dict stack
/showpage { } def % Redefine showpage, { } = null proc
0 setgray 0 setlinecap % Prepare graphics state
1 setlinewidth 0 setlinejoin
10 setmiterlimit [ ] 0 setdash newpath
/languagelevel where % If level not equal to 1 then
{pop languagelevel % set strokeadjust and
1 ne % overprint to their defaults.
{false setstrokeadjust false setoverprint
} if
} if
} bind def
/EndEPSF { %def
count op_count sub {pop} repeat % Clean up stacks
countdictstack dict_count sub {end} repeat
b4_Inc_state restore
} bind def
%%EndProlog
%%BeginSetup
%%IncludeFont: Helvetica Times-Italic
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
/pgsave save def
%%EndPageSetup
%EndProlog
BeginEPSF
%%BeginDocument: form-cms1500
=========== end.ps
%%EndDocument
EndEPSF
pgsave restore
/Helvetica findfont 10 scalefont setfont
22.5 675 moveto (X) show
/Times-Italic findfont 12 scalefont setfont
22.5 653 moveto (Karl Hammar) show
showpage
%%EOF
===========
Regards,
/Karl Hammar
More information about the texhax
mailing list.