I'm using Flying Saucer to create PNG image files from XHTML. I then use another facility to collect these into a PDF, along with a bunch of other text n images.
While I could convert our PDF export processing to iText, that would be a rather large undertaking....
The problem I have is that some XHTML content I have need to be paginated when exported to PNG image files. I'm OK with just a simple 'clip-style' break between the image files.
Here's what I'm using just to render the entire content to a single file and it works well.
File file = File.createTempFile("AAA", "." + suffix);
XHTMLPanel panel = new XHTMLPanel();
panel.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
InputStream is = <create content>;
panel.setDocument(is, "");
Graphics2DRenderer renderer = new Graphics2DRenderer();
renderer.setDocument(panel.getDocument(),"");
BufferedImage img = new BufferedImage(DEFAULT_WIDTH,
DEFAULT_HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = (Graphics2D) img.getGraphics();
graphics.setColor(Color.white);
graphics.fillRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
renderer.layout(graphics,null);
renderer.render(graphics);
ImageIO.write(img, suffix, file);
However, some of my content 'spans' a couple of pages and the processing above just displays the top DEFAULT_HEIGHT pixels and clips the remainder.
Is there a way to 'iterate' through the panel content (vertically) and render, say X pixels of content to unique image files? That's sort of what ITextRenderer does, but how can I render the individual pages to separate image files?