Search code examples
htmlpdfpostscriptpdftkhtmldoc

HTMLDOC - aligning text to bottom of page


I have an html page being generated which creates some dynamic content, gets converted to ps, and sent out via snailmail.

The length of the document depends on how many items are in the dynamically generated list near the beginning of the page. The main problem here is getting the recipient's address consistently at the bottom of the page so that it fit's in the letter's address window.

I can't find much in the documentation about this specific case: http://www.msweet.org/documentation/project1/HTMLDOC.html

I CAN use <!-- NEED x -->, but this in itself doesn't ensure that the address stays in the same spot every time, unless we always use 2 pages. The "FOOTER" functionality in HTMLDOC doesn't parse html, and doesn't work with multiple paragraphs. (It's not JUST the address I want at the bottom of the page, but everything below and including the last line break "PLEASE RETURN THIS SLIP...")

Any ideas? I can get this working by generating 2 pages each time, but this looks pretty terrible and is a waste of paper. The page layout is as follows:


[HEADER LEFT DATE] [HEADER RIGHT LOGO]

Dear __________,

Please return the following items:

  • item 1
  • item 2
  • ...
  • item n

Please return the equipment to: [Addr 1]

[Long return instructions]

Thanks for choosing ______,


RETURN SLIP

[Customer Address] <- needs to be statically placed on page

(example: https://i.sstatic.net/m5vnF.jpg red box is the address, and needs to be lower on the page)


Solution

  • First, why are you even generating PostScript output and send it out by snail mail? Most people nowadays know better to handle PDF documents than they do know about PostScript documents.

    HTMLDOC can also generate PDF output. Did you know?

    So, I would propose a different workflow for you:

    1. Let HTMLDOC generate PDF output. But don't put address, footer and stuff on the page(s) (yet).
    2. Generate your addresses and your footers and other dynamic stuff separately as PDF (you could also use HTMLDOC for this). This will give you more control over the exact placement of the text, undisturbed from your dynamic document content.
    3. Merge the document and the address/footer/etc. pages into one PDF page, using pdftk's command line power (stamp or background or multistamp/multibackground would be feasible sub-commands to look into).

    I'm pretty sure this setup will give you much less headaches than your current one -- even if it looks more complex at first sight.

    If you insist on PostScript output, you can still convert the PDFs to PostScript (recommended tool for this: pdftops from Poppler or from XPDF; possibly also Ghostscript, but then make sure to have the most recent release and use -sDEVICE=ps2write, NOT ...=pswrite!).