docx4j

Change the page orientation in middle of doc

妖精的绣舞 提交于 2019-12-07 14:24:57
问题 I need to set landscape to some pages of a document. I tried this code: SectPr sectionLandscape = objectFactory.createSectPr(); String rsidR = sectionLandscape.getRsidR(); SectPr sectionPortrait = objectFactory.createSectPr(); sectionPortrait.setRsidR(rsidR); sectionPortrait.setRsidSect(rsidR); PgSz landscape = new PgSz(); landscape.setOrient(STPageOrientation.LANDSCAPE); landscape.setH(BigInteger.valueOf(11906)); landscape.setW(BigInteger.valueOf(16383)); sectionLandscape.setPgSz(landscape);

Generate .docx from HTML with Base64 images with docx4j

拈花ヽ惹草 提交于 2019-12-07 12:18:15
问题 I'm trying to generate a .docx from a HTML String with docx4j in Java , which contains Base64 images inside. At the moment, I'm being able to generate the Word and download it (inside a Vaadin project), but the images doesn't insert properly. However, if I put the HTML code into a index.html page, they do show correctly! The code I'm using is this: try{ String html = "<html xmlns='http://www.w3.org/1999/xhtml'><head><style type='text/css'>.p-nombreProceso { font-family: Arial; font-size: 48px

DOCX4J Insert a line break

女生的网名这么多〃 提交于 2019-12-07 02:45:27
I have a variable in a DOCX that I want to replace with a value. First, that variable is not placed at the beginning of the line but after some tabs. My value is a postal address and I want to have the street and zip code (+city) in different line with the same indentation. The street replace the variable in his line, and the zip code is in a new line like that: 4 Privet Drive Little Whinging This is the XML for the variable: <w:p> <w:pPr> <w:tabs> <w:tab w:val="left" w:pos="6120"/> </w:tabs> <w:ind w:firstLine="6300"/> <w:rPr> <w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/> <w:b/> <w

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

情到浓时终转凉″ 提交于 2019-12-06 13:39:13
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? My problem was - missing proper True Type Fonts on linux server. The default fonts where inserted instead (without my code pages). I solved the problem installing the default Ms Windows

How can I detect org.docx4j.wml.instrText when parsing DOCX with docx4j?

爱⌒轻易说出口 提交于 2019-12-06 06:21:12
I want to pars a docx file with docx4j library. I need to detect org.docx4j.wml.instrText objects but actually it returns org.docx4j.wml.Text instead of org.docx4j.wml.instrText. I found a solution that was working with older version of this library here: http://www.docx4java.org/forums/docx-java-f6/can-i-just-don-t-load-contents-of-w-instrtext-into-text-t193.html Actually this solution: ((javax.xml.bind.JAXBElement)((org.docx4j.wml.Text) o).getParent()).getName().getLocalPart() But with the latest update it does not work. Could you please tell me what changes I have to make on this code?

Generate .docx from HTML with Base64 images with docx4j

本小妞迷上赌 提交于 2019-12-06 03:52:46
I'm trying to generate a .docx from a HTML String with docx4j in Java , which contains Base64 images inside. At the moment, I'm being able to generate the Word and download it (inside a Vaadin project), but the images doesn't insert properly. However, if I put the HTML code into a index.html page, they do show correctly! The code I'm using is this: try{ String html = "<html xmlns='http://www.w3.org/1999/xhtml'><head><style type='text/css'>.p-nombreProceso { font-family: Arial; font-size: 48px; color: magenta; text-align: center; } .li-seccion { font-family: Arial; } .a-seccion { font-family:

How to read word document and get parts of it with all styles using docx4j

这一生的挚爱 提交于 2019-12-06 01:34:49
I am using docx4j to deal with word document formatting. I have one word document which is divided in number of tables. I want to read all the tables and if I find some keywords then I want to take those contents to another word document with all the formatting. My word document is as follow. Like from above I want to take content which is below Some Title. Here my keyword is Sample Text. So whenever Sample Text gets repeated, content needs to be fetched to new word document. I am using following code. MainDocumentPart mainDocumentPart = null; WordprocessingMLPackage docxFile =

Change the page orientation in middle of doc

匆匆过客 提交于 2019-12-05 21:47:19
I need to set landscape to some pages of a document. I tried this code: SectPr sectionLandscape = objectFactory.createSectPr(); String rsidR = sectionLandscape.getRsidR(); SectPr sectionPortrait = objectFactory.createSectPr(); sectionPortrait.setRsidR(rsidR); sectionPortrait.setRsidSect(rsidR); PgSz landscape = new PgSz(); landscape.setOrient(STPageOrientation.LANDSCAPE); landscape.setH(BigInteger.valueOf(11906)); landscape.setW(BigInteger.valueOf(16383)); sectionLandscape.setPgSz(landscape); mdp.addObject(sectionLandscape); It creates this xml code: <w:sectPr> <w:pgSz w:w="16383" w:orient=

Reading equations & formula from Word (Docx) to html and save database using java

◇◆丶佛笑我妖孽 提交于 2019-12-05 07:21:13
问题 I have a word/docx file which has equations as under images I want read data of file word/docx and save to my database and when need I can get data from database and show on my html page I used apache Poi for read data form docx file but It can't take equations Please help me! 回答1: Word *.docx files are ZIP archives containing XML files which are Office Open XML. The formulas contained in Word *.docx documents are Office MathML (OMML). Unfortunately this XML format is not really well known

How to apply new line in docx file generation using DOCX4J

别来无恙 提交于 2019-12-04 08:05:52
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.getWmlObjectFactory(); WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(); P spc = factory