docx4j

How to change font encoding when converting docx -> pdf with docx4j?

余生长醉 提交于 2019-12-22 18:28:22
问题 When I'm a converting docx document to pdf my national characters transform into "#" marks. Is there any way to set a font encoding for pdf documents? I used xdocreport in the past and it can handle that, but I had problems with images, headers and footers. Docx4j manages to do this, but not fonts. After conversion, fonts have ANSI encoding while I'd like to have windows-1250. Is there an option to set this? 回答1: My problem was - missing proper True Type Fonts on linux server. The default

How to change font encoding when converting docx -> pdf with docx4j?

为君一笑 提交于 2019-12-22 18:28:15
问题 When I'm a converting docx document to pdf my national characters transform into "#" marks. Is there any way to set a font encoding for pdf documents? I used xdocreport in the past and it can handle that, but I had problems with images, headers and footers. Docx4j manages to do this, but not fonts. After conversion, fonts have ANSI encoding while I'd like to have windows-1250. Is there an option to set this? 回答1: My problem was - missing proper True Type Fonts on linux server. The default

how to convert doc,docx files to pdf in java programatically

血红的双手。 提交于 2019-12-22 14:58:09
问题 I am able to generate pdf from docx file using docx4j.But i need to convert doc file to pdf including images and tables. Is there any way to convert doc to docx in java . or (doc to pdf)? 回答1: docx4j contains org.docx4j.convert.in.Doc, which uses POI to read the .doc, but it is a proof of concept, not production ready code. Last I checked, there were limits to POI's HWPF parsing of a binary .doc. Further to mqchen's comment, you can use LibreOffice or OpenOffice to convert doc to docx. But if

How to apply new line in docx file generation using DOCX4J

前提是你 提交于 2019-12-21 14:12:38
问题 By the tutorials that I have seen. I learned how to add text on generating a docx file. but then Every time I add a line of text. I noticed that there is always a space between the first line of text and the second line of text. just like hitting the enter key twice. I know that the main cause is that everytime I add a line of text, I use a paragraph. and a paragraph starts with a space after another paragraph. This is how I add a text ObjectFactory factory; factory = Context

How to apply new line in docx file generation using DOCX4J

天涯浪子 提交于 2019-12-21 14:12:11
问题 By the tutorials that I have seen. I learned how to add text on generating a docx file. but then Every time I add a line of text. I noticed that there is always a space between the first line of text and the second line of text. just like hitting the enter key twice. I know that the main cause is that everytime I add a line of text, I use a paragraph. and a paragraph starts with a space after another paragraph. This is how I add a text ObjectFactory factory; factory = Context

docx4j - Why is the text truncated of spaces?

☆樱花仙子☆ 提交于 2019-12-21 06:00:50
问题 Here is the code: P para = factory.createP(); R run = factory.createR(); Text text = factory.createText(); text.setValue( " abc " ); run.getContent().add( text ); para.getContent().add( run ); wordMLPack.getMainDocumentPart().add( para ); Here is the docx generated: The heading and trailing spaces are all missing. 回答1: You need to tell docx4j to explicitly preserve whitespace in your Text instances (the underlying format is XML of course, which tends not to pay much heed to whitespace).

docx Template Docx4j replacing text in Java

强颜欢笑 提交于 2019-12-20 07:12:35
问题 Im new to Docx4j and my task is to replace some Text of a docx Template. I read the getting Started Guide of docx4j but I don't think I fully understood the whole concept. Well Anyway... I already tried [the unmashalling Template of Docx4j][1], which worked fine with the given docx, but then I got the same Problem when I tried it on my own template The Exceptions say, that the HashMap doesnt contain valid keys or values, and therefore it doesnt replace the placeholders. I replaced the <w

docx Template Docx4j replacing text in Java

杀马特。学长 韩版系。学妹 提交于 2019-12-20 07:12:06
问题 Im new to Docx4j and my task is to replace some Text of a docx Template. I read the getting Started Guide of docx4j but I don't think I fully understood the whole concept. Well Anyway... I already tried [the unmashalling Template of Docx4j][1], which worked fine with the given docx, but then I got the same Problem when I tried it on my own template The Exceptions say, that the HashMap doesnt contain valid keys or values, and therefore it doesnt replace the placeholders. I replaced the <w

Reading .docx file in java

我怕爱的太早我们不能终老 提交于 2019-12-20 06:46:20
问题 I am trying to read one file in java, following is the code : public void readFile(String fileName){ try { BufferedReader reader= new BufferedReader(new FileReader(fileName)); String line=null; while((line=reader.readLine()) != null ){ System.out.println(line); } }catch (Exception ex){} } It is working fine in case of txt file. However in case of docx file, it is printing weird characters. How can i read .docx file in Java. 回答1: import java.io.File; import java.io.FileInputStream; import java

Instead of rendering tables and other html tags in docx these are saved as plain text using docx4j-ImportXHTML

和自甴很熟 提交于 2019-12-18 09:14:42
问题 I want to render html code to docx. Instead of rendering html(i.e. tables in tabular format) it simply writes html code in it as plain text. I am using docx4j-ImportXHTML jar. I used the code from here and modified it to save in a file. What am I doing wrong? public static void xhtmlToDocx(String xhtml, String destinationPath, String fileName) { File dir = new File (destinationPath); File actualFile = new File (dir, fileName); WordprocessingMLPackage wordMLPackage = null; try { wordMLPackage