I'm not sure I unserstand exactly what you are trying to accomplish,
but if I understand corerctly, then the following approach might work
for you.
RTF, like PDF is a text-based, document formatting and markup
specification. With RTF, however, you can edit text or insert new
text in the doument without invalidating the document's internal
structure. PDF requires byte offsets be stored within its internal
structure so modifying the document after creation invalidate these
offsets and makes the document unreadable by the Adobe PDF viewer.
To see what I mean about editing RTF, open Word and type some text
into a document and then save it as RTF. Then open the RTF document
in Notepad and edit the text you entered. Reopen the document in Word
and you will see the changes that you made.
To approach your problem. Put markers in your documents where you
need to place each element, like <# CompanyName #> to create an RTF
template document. Then write a simple program that can fetch data
from your database, XML files, and/or text files and merge it all into
the RTF template (essentially a search and replace task). With
further experimentation, you'll find you can even dynamically embed
images into your documents, create tables and more. Some of this
(such as working with images) can be accomplished by creating small
RTF documents, opening them and removing portions into separate text
files. These text files are then data sources for the merge process.
Naturally you'll want the template to be as close to final as possible
before performing the merge step.
If your documents are very consistent but each customized, such as
happens during a mail-merge operation, you'll find this approach
simple and effective. If you absolutely must have the final output in
PDF, then use a converter tool like [
http://www.eprintdriver.com/to_pdf/RTF-to-PDF-ex.html ] to do a final
pass and convert the RTF to PDF.
Should you need to kick these documents up a notch, as Emeril might
say, other easily found software tools can be used to polish the PDF
output further. This would be useful if you wanted to merge multiple
files, add thumbnails, incorporate security, embed word-search indexes
or include other high-end PDF features with the documents.
Good luck. |