Converting Text Files to PDF using the Datalogics PDF Java Toolkit

Sample of the Week:

A few posts ago, I discussed the Talkeetna module built on top of the Datalogics PDF Java Toolkit and how it simplifies creating PDF files programmatically. That article showed a simple “Hello World” example. This Sample of the Week is equally as simple but it is it’s simplicity that demonstrates the elegance of the Talkeetna module. To convert a text file into PDF requires just a few lines of code.

The reason the code can be so terse is because Talkeetna does all the heavy lifting for you. Of course, you can define your own page margins but if you don’t, Talkeetna will default to one inch on all sides. You can also define a font, font size, and font style… but if you don’t Talkeetna will default to Times 12 point. For that matter, Talkeetna will create reasonable defaults for any of it’s text flow elements that have an HTML corollary… which means that if you write code that does nothing but add a bunch of paragraphs to the LayoutEngine, it will come out looking good… but it will also be well structured PDF.

Talkeetna is included in the Datalogics PDF Java Toolkit. When you evaluate or license the toolkit, you get Talkeena so you can either get the evaluation and run the Gist referenced above or you can just check out the input and output files to see what it does.

Share this post with your friends

Share on facebook
Share on twitter
Share on linkedin

Leave a Comment

Your email address will not be published. Required fields are marked *