I have a document in a scala.xml
tree (this is easy to convert to whatever else) that I'd like to take and turn into a series of PNG files.
For example, the document might look like this:
<doc
title="My Document"
author="John Doe"
created="1 July 1977"
published="19 July 1799"
>
<section heading="An Analysis of Multiparticles"> <!-- Section 1 -->
<p>Paragraph one goes here</p> <!-- INTRODUCTION! -->
<p>Paragraph two goes here</p>
</section>
<section heading="Conclusion of Multiparticles"> <!-- Section 2 -->
<p>Paragraph one goes here</p> <!-- INTRODUCTION! -->
<p>Paragraph two goes here</p>
</section>
</doc>
I'd then like to turn that document into a PNG that looks something like this minus the red lines under made-up words (I'd supply the rules for formatting, typefaces to use, etc etc):
And, if possible, longer documents should be able to be "paginated" into any number of PNG files that would flow into the next one after hitting say, 500px of height or something.
If there is an existing Java library/package to do this that does any part of this (or a couple that manage to do it all put together)—great! Otherwise, I'd like to know where I should start for writing something to do this in Scala (preferably) or Java.
Thanks!
You want to use the iText library. This lets you manipulate the document, generate a PDF and whatever else you want to do with it, very advanced, very powerful, very Java. Once you have a PDF you can export its contents to any format you would like, there are lots of PDF -> PNG options on the internet.
From the front page: