java - Apache POI HWPF - problem in convert doc file to pdf -


I am currently working with the Java project to use Apache Poison. Now in my project I want to convert the doctor file into a PDF file. The conversion was successfully completed but I will not only get the text in PDF, not text text or text color. My pdf file black & amp; White. While my doctor file is painted and has different style of text.

This is my code,

  POIFSFileSystem fs = null; Document document = new document (); Try {System.out.println ("Begin Testing"); FS = new POIFSFileSystem (new file inputstream ("/ document / test2.doc")); Hppf document doc = new hppf document (fs); WordExtractor We = New WordExtractor (Doctor); Outputstream file = new file optest string (new file ("/ document / test.pdf")); PDF Author Author = PDFDriver.Testence (document, file); Range range = doc.getRange (); Document.open (); Author.setPageEmpty (true); Document.newPage (); Author.setPageEmpty (true); String [] paragraph = we.getParagraphText (); For (int i = 0; i & lt; paragraph length; i ++) {org.apache.poi.hwpf.usermodel.Paragraph PR = range.getParagraph (i); // Character Run run = PR.jetctrine (i); // run.setBold (true); // run.setCapitalized (true); // run.setItalic (true); Paragraph [i] = paragraph [i] .replaceAll ("\\ cm? \ R? \", ""); System.out.println ("Length:" + Paragraph [i] Length ()); System.out.println ("Paragraph ++:" + Paragraph [i] .toString ()); // Add paragraph for document document.add (new paragraph [paragraph [i]);); } System.out.println ("Documents Complete the Doc"); } Hold (exception e) {System.out.println ("exception during trial"); E.printStackTrace (); } Close the {// document document} at the end. Close ();   

Please help me.

Thnx in advance

If you look at Apache box, a good example of reading some style information from the HWPF document is. Code in the vaccine produces HTML based on WPPF content, but you should see that such a thing works for your case.

Vaccine class

One thing to note about word documents is that in one of the character moves, everything applies to the same formatting. A paragraph is therefore composed of one or more character runs. Some styles are applied to the paragraphs, and the other part is done on the run. Depending on what format you want, it can be on paragraph or run.


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -