Hey all,
I've been wandering around the mailing list for awhile and have seen a
few people ask this question but haven't seen any with a response.
I'm currently using the iText package to convert HTML directly into a
PDF document. I'm using the following code:
public byte[] getPDF()
{
//create a document
Document document = new Document(PageSize.A4.rotate());
//we need an output stream
ByteArrayOutputStream output = new ByteArrayOutputStream();
try
{
//create PDF
PdfWriter.getInstance(document,output);
//parse our html
HtmlParser.parse(document,new InputSource(new
StringReader(this.rpt.getHtml())));
}
catch(Exception e)
{ e.printStackTrace(); }
//return a bytearray to be sent to the browser
return output.toByteArray();
}
This code actually does create the PDF and I can send the byte stream
back to the user for downloading. However, there are a couple of
errors. First of all, despite using the .rotate() functionality as
suggested in the example, my page still appears in portrait form. One
of my project requirements is for the PDF to be created as a landscape
layout so this is pretty important to me. Is there an issue with
using the HtmlParser and landscape format?
Secondly, I have a six column layout (though it will adjust) where all
of the columns are the same width. When the PDF conversion is done,
the first column takes up one half of the page and the other five
columns split the remainder. It seems that no matter what I set my
widths to in the HTML document, I still have this result. Does anyone
have any suggestions for doing this?
I understand that using FO-P is probably a better solution, but I'm
trying to avoid the HTML->XML->FO->PDF translation process and would
like to keep things as simple as possible.
Thanks for your time all!
~ Andrew Tomaka
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions