[External Email] Re: creating a pdf version of a complicated form, populated with data from a database

Christopher Ryan cryan at binghamton.edu
Tue Apr 9 17:44:00 CEST 2024


Thanks everyone for the ideas. Lots to think about!  Not recreating all the
lines, boxes, and other adornments on the form makes sense.

We are a small government agency and do not have a decent, full-fledged
electronic medical record.  We are about to resume (hopefully large-scale)
blood lead testing for children. We were doing it pre-pandemic, and I
remember the workflow, data management, and preparations for billing being
very tedious.  I've created a REDCap project to manage most of the
operation. R has a nice capability to interface with REDCap via an API. R
is the only programming language I have any facility with. As the saying
goes, "If all you have is a hammer, everything looks like a nail."

--Chris

On Fri, Apr 5, 2024 at 9:09 AM <karl at aspodata.se> wrote:

> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/texhax/attachments/20240409/e71ecb75/attachment.htm>


More information about the texhax mailing list.