Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Headers, Footers and Variable Length Body

Question

I've got an assignment to create PDF letters from a database. The letter header and footer are already created in PDF and I just need to add pieces to the body of the letter. Some letters will have a couple of paragraphs and some will have more. In some cases, the number of text lines will push the letter to two pages.

The paragraphs can be a simple sentence or up to perhaps 8 to 10 lines in total length.

Here's my question: Can I have a 'shell' PDF with a header and footer (with form fields so I can include an address, addressee and other information) and then programmatically create the body of the letter? I just don't know what length limitations are and if there is an easy way to 'build' the letter so it looks right and no information is missing or overlapping because of the length of the text. If it spills over into a second page, I'd like the header to be blank and the footer remain exactly as what was on the first page.

Thanks in advance.

Answer

Yes, what you're trying to do is possible.

You can have a template PDF file that you load into Quick PDF Library using the LoadFromFile function and then draw the body text onto the PDF and then save it as a new file using the SaveToFile function.

The DrawHTMLTextBox function is your best bet for drawing the text as it allows you to easily draw text over multiple pages. Basically what happens is that you specific the left and top coordinates for where the text box should be drawn and then you also specific the width and height of the text box. Any of the text that does not fit into the height of the text box will be returned as a string that can then be used again with the DrawHTMLTextBox function on the second page and so on.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum