Hi all, I have an application that uses tinyMCE to allow users to input Word formated text. This text is translated into HTML fragments. These fragments need to be included in some PDF documents. I use plain itext for the generation of these documents. It works fine with some exceptions. One would be that it doesn't keep the undelined text underlined ( I think this is related to styles ) and the biggest problem that I face is using dicritics. I use dicritics just fine using a font that has them, but I can't get HTMLWorker to use the same font.
I started from this example : http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg20413.html I have created a html that contains all the posibilities I have thought of : HTML code, ASCII code, UTF-8 Character. This is my code : public void parseByWorker() throws DocumentException, IOException { Document document = new Document(); // Adaugate de mine - solutii BaseFont bf = BaseFont.createFont("ARIALUNI.TTF", BaseFont.IDENTITY_H, true); Font font = new Font(bf, 18, Font.BOLD); FontFactory.register("ARIALUNI.TTF"); StyleSheet st = new StyleSheet(); st.loadTagStyle("body", "face", "arial unicode ms"); st.loadTagStyle("body", "encoding", "Identity-H"); st.loadTagStyle("body", "leading", "12,0"); try { FileReader fileReader = new FileReader("roumanian.html"); PdfWriter.getInstance(document, new FileOutputStream("worker.pdf")); document.open(); // solutie ArrayList p = HTMLWorker.parseToList(fileReader, st); for (int k = 0; k < p.size(); ++k) document.add((Element)p.get(k)); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(new Phrase()); document.add(Chunk.NEWLINE); document.add(new Phrase(new Chunk("Not showing >\u015f< no font specified"))); document.add(Chunk.NEWLINE); document.add(new Phrase(new Chunk("Showing \u015f because of the right font", font ))); document.close(); // worker.parse(stringReader); // worker.parse(fileReader); document.close(); } catch (DocumentException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println("Print End"); } I attached the full java class, the html file and the result. Thanks for any suggestion, NArcis PS : I could attach the used font also, but I don't know about the copyright....
|
worker.pdf
Description: Adobe PDF document
TwoOneOne.java
Description: Binary data
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/