Vladimir Šetka wrote:
> Hello Mr Lowagie,

Please don't mail me personally, use the mailing list instead.

> I'm trying to generate PDF from HTML automatically. This is the way I 
> tried it
> 
> Document doc = new Document(PageSize.A4, 80, 50, 30, 65);
> PdfWriter.GetInstance(doc, new System.IO.FileStream("output.pdf", 
> FileMode.Create));
> HtmlParser.Parse(doc, "input.html");
> 
> The input HTML document looks like MojHtml.html in attachment
> 
> and the output PDF like htmlParser.pdf
> 
> What can I do to display čćđ? I tried changing html document encoding to 
> windows-1250 and ISO equivalent, but it didn't work. I tried with HTML 
> entities which also didn't work, as presumed. I got it to work with this 
> code, using HtmlWorker:
> 
> PdfWriter.GetInstance(doc, new System.IO.FileStream("output.pdf", 
> FileMode.Create));
> StreamReader sr = new StreamReader("input.html", Encoding.UTF8);
> ArrayList ListaElemenata = 
> iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null);
> 
> for (int i = 0; i < ListaElemenata.Count; i++)
> {
>     IElement ielement = (IElement)ListaElemenata[i];
>     ArrayList chunks = ielement.Chunks;
>   
>     for (int j = 0; j < chunks.Count; j++)
>     {
>         Chunk chunk = (Chunk)chunks[j];
>         chunk.Font = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 
> "Cp1250", 12);
>         doc.Add(new Phrase(chunk));
>     }
> }
> doc.Close();
> 
> With this code, output.pdf looks like htmlWorker.pdf in attachment. I 
> got the letters, but lost formatting. How can I get the letters and keep 
> the formatting. Am I missing something basic?
> 
> Thank you for your time,
> Vladimir Šetka

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to