docx4j

DOCX4J - Copying inbetween two markers

若如初见. 提交于 2019-12-12 05:00:03
问题 I've done a simple replace with DOCX4J, thanks to this awesome guide. But now I'm trying to do something more complicated. What I'd like to do is find my marker text #1 within the document, find my marker text #2 within the document, and copy EVERYTHING inbetween the two. I will then be pasting that content X number of times and doing further alterations. Does anyone know how I would do this, and possibly point me to the key functions needed? 回答1: In the general case, that's not a simple

Docx4j - chaging language settings for docDefaultStyle/proper applying custom(or changed) stock styles to any text in docx

随声附和 提交于 2019-12-12 04:56:02
问题 I'm trying to use mine defined(changed) styles in Styles styles = mp.getStyleDefinitionsPart ().getJaxbElement (); to change styling for my entire table/individual table cells. I managed to make it by setting the properties in RPr runProperties like this: in method applying style for table cells I use this: setFontFamily(runProperties, style.getFontFamily()); private static void setFontFamily(RPr runProperties, String fontFamily) { if (fontFamily != null) { RFonts rf = runProperties.getRFonts

DOCX4J XML how to get the “value” of a JAXBNodes

試著忘記壹切 提交于 2019-12-12 03:48:58
问题 I want to bind some XML variable in a docx file (my var are in that pattern $varname$). So I use a function which return a List<Object> with the result of my search over the document. String xpath = "//w:r[w:t[starts-with(text(), '$')]]"; List<Object> list = this.getDocumentPart().getJAXBNodesViaXPath(xpath, false); if(!list.isEmpty()){ for(int i = 0; i < list.size(); ++i){ System.out.println(list.get(i).getClass()); } } The result of the print is: class org.docx4j.wml.R class org.docx4j.wml

How to correctly position a header image with docx4j?

本秂侑毒 提交于 2019-12-12 02:43:00
问题 I am trying to convert this Word document with a header showing an image on the right http://www.filesnack.com/files/cduiejc7 to PDF using this sample code: https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ConvertOutPDF.java Here's the result: http://www.filesnack.com/files/ctjs659h While the Word document has the header image on the right, the converted PDF shows it on the left. How can I make docx4j to reproduce the original document as PDF? 回答1: Your

Render docx file in a browser

懵懂的女人 提交于 2019-12-12 02:09:06
问题 I'm using docx4j to convert a microsoft word document into a pdf then displaying it in a browser http://www.docx4java.org/trac/docx4j and it works well for a preview. The problem I'm facing is that this conversion loses most of the microsoft word document formatting. Page breaks and fonts don't transfer into the PDF format properly and even though I'm using standard font types docx4j doesn't come with them. In a Linux Tomcat hosted scenario fonts are not found and throw exceptions as it falls

Optimize docx4j performance

♀尐吖头ヾ 提交于 2019-12-11 20:13:37
问题 I am using docx4j 2.8.1 to replace texts and a logo within the word files. Now I want to improve performance since the processing of about 50 documents is quite slow. What options are recommended to increase performance of docx4j? The code to replace the strings (not the logo) looks like: String xml = XmlUtils.marshaltoString(documentPart.getJaxbElement(), true); HashMap<String, String> mappings = buildReplaceMap(userData); Object obj = XmlUtils.unmarshallFromTemplate(xml, mappings);

WordprocessingMLPackage.save not saving bindings - Docx4j

元气小坏坏 提交于 2019-12-11 19:49:43
问题 I am trying to set text/images to content controls in a docx. BindingHandler.applyBindings seems to apply the bindings to the main doc part. I can see the value being changed on debug. But when I save it using WordprocessingMLPackage.save or Docx4J.save, I dont see the newly bound text/image in the output document. What could possibly be the reason? 来源: https://stackoverflow.com/questions/22869070/wordprocessingmlpackage-save-not-saving-bindings-docx4j

Setting the font and style of jeditorpane

陌路散爱 提交于 2019-12-11 19:47:41
问题 I am currently developing an application for this company as my last year of studies project, and in this application there's this function that allows you to print a paper, so i used the jeditorpane obviously, with the Charles Bell HTMLEditorKit for the predefined functions like setting the font and printing, etc... and there's this pre-written text that i have to load from a text file and then the program is supposed to add some text inside the file automatically, and the user also is

How create three TOC with diffrent styles in docx by java?

不打扰是莪最后的温柔 提交于 2019-12-11 15:14:50
问题 How can I create three or more TOC in docx file that one of them is for Headings level 1, 2, 3 and others are for another styles which are created by program? For example, I create a style for table title and I want to create a TOC for paragraphs with this style. And I want these TOCs to be in special paragraphs not at the end of the file. Which one is better to do this, Apache-poi? docx4j ? Aspose? I write my other code with apache-poi. 回答1: Using Aspose.Words for Java, you can use

Word, docx4j and content control text formatting

会有一股神秘感。 提交于 2019-12-11 12:08:06
问题 I'm using docx4j to create Word documents using a Word template. The template contents control which in the document are filled with text by my Java code. The problem is that the formatting I have added to some of the controls has no effect. I have tried formatting with both text content controls and rich text content controls. In fact, the entire document appears grey (including the image in the document header) so I'm not sure that the problem is specific to docx4j. Here is my code: private