Questions tagged [docx4j]
Docx4j is an open source (ASLv2) Java library for manipulating Microsoft OpenXML files (Word docx, Powerpoint pptx, and Excel xlsx) via JAXB
869
questions
0
votes
1
answer
41
views
Using docx4j to convert .docx to .pdf
I'm trying to convert .docx files to .pdf files. Now I have the following code:
class DocxToPdf {
fun convert(inputFileLocation: FileInputStream, outputFileLocation: FileOutputStream) {
...
0
votes
0
answers
36
views
Html to docx with Docx4j break table when page skip
I using docx4j to generated a docx from html string, works great but the tables broken when the page skip.
This the code.
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(...
0
votes
1
answer
68
views
Upgrading to 11.4.6 causes java.lang.NoClassDefFoundError: Could not initialize class org.docx4j.fonts.IdentityPlusMapper
Case:
Writing a docx as pdf using WordprocessingMLPackage and setting the fontMapper using IdentityPlusMapper() from org.docx4j.fonts to map the fonts in the document we receive:
java.lang....
1
vote
0
answers
32
views
Docx4j consider using Xerces Warning
In a Spring MVC server I have this warning every time I use docx4j to generate a docx. The server functions well, but I have a huge log with this warning
2022-04-27 18:00:46.241 [http-nio-8080-exec-3] ...
0
votes
1
answer
21
views
Docx4j Put image and text in the same run
Is there any way to put three words(one below another) and an image exactly next to them in the same run inside a P element?
I am trying this but it is not working. It displays the String without new ...
0
votes
0
answers
35
views
Not able to parse base64 image into xhtml using Document jsoup while converting HTML to Docx word file
I want to convert HTML data to Docx word file and for that I am first converting html to xhtml using jsoup library.
I have shared a code snippet here
private static String htmlToXhtml(String ...
0
votes
0
answers
30
views
Replace contents between headings
So what I am trying to do is I want to fetch Heading wise data from word via docx4j and want to replace the data that is in those Headings, I do not want to change the heading text just want to remove ...
0
votes
1
answer
53
views
How to set numbering format in lists docx4j
I’m trying to create numbered/bulleted lists but I want to be able to set which number format to use, example LOWER_LETTER, UPPER_LETTER, UPPER_ROMAN, etc.
I referred to this: http://useof.org/java-...
0
votes
1
answer
19
views
Add a caption to an image with docx4j
i would like to link a caption to an image using docx4j.
BinaryPartAbstractImage imagePart;
imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);
Inline inline = imagePart....
0
votes
0
answers
36
views
How to move to mail merge field position, remove it then insert an image in the same position
Using docx4j, I'm trying to populate many merge fields with text values in a docx document, and it worked correctly. I have a merge field that should be replaced by an image. Is there a way to move to ...
0
votes
0
answers
38
views
Docx4j TOC generation getting wrong page number
I'm using docxj4 for generating Word documents, and now I need to generate a table of contents. I am using docx4j-export-fo library for that purpose. But it produces the wrong numbering.
I need to ...
0
votes
1
answer
51
views
How to generate TOC
My Version:jkd11
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-MOXy</artifactId>
<version>11.4.5</...
0
votes
2
answers
159
views
Docx4j - Docx to Image convertion
I am trying to convert docx into png file using doc4x and running into some error.
Gradle entries,
// https://mvnrepository.com/artifact/org.docx4j/docx4j
implementation group: 'org.docx4j', name: ...
0
votes
1
answer
66
views
Docx4j ImportXHTML: Hyperlink around image not working
I want to add a image in my Word doc using docx4j lib. When click on that image i want to open a link. But not able to open the link. Also the link is visible in my document (it should be hidden as ...
0
votes
1
answer
83
views
Dovx4J: Enabling page numbers in ToC results in TocException
I am using Docx4j in an internship project and when I try to generate a ToC with page numbers it does not work.
Executing the code with
if (template.isGenerateToc()) {
Toc....
0
votes
0
answers
30
views
Inserting SVG into docx document
I want to insert an svg into a docx document. I used this post as a guide but it seems outdated:
https://www.docx4java.org/forums/docx-java-f6/add-svg-to-document-t2927.html
I am seeing the error:
[...
2
votes
1
answer
60
views
How to Handle Breaking Change in Interface of docx4j Class "FlatOpcXmlCreator" in V11.3.2 (aka V8.3.0)
I'm about to update our project's dependencies and found out docx4j has changed it's interface of class FlatOpcXmlCreator. The get() method is now not only deprecated but completely deactivated as the ...
0
votes
0
answers
20
views
Word field definition issue after save
I have field definition in Word 2016 (Office 365 same problem) like this
<w:r>
<w:fldChar w:fldCharType="begin"/>
...
0
votes
1
answer
109
views
AEM/Jetty and javax.xml.transform.TransformerFactory
We are using the docx4j library to add watermark to the pptx files. Java code below:
public static void main(String[] args) {
try {
OutputStream object = new FileOutputStream("C:\\test.pptx&...
0
votes
0
answers
70
views
Conversion of docx to pdf using docx4j library in java
If i am trying to convert the docx file to pdf file
Code :
InputStream is = file.getInputStream();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
File outputFile = new File(...
1
vote
0
answers
65
views
Docx4j variableReplace() with string containing "&"
Replacing '&' with & fixes the problem
I'm currently struggling with the method variableReplace() from docx4j.
Basically I'm reading in json-files and want to replace the read json ...
0
votes
1
answer
48
views
Replace a text with trackchange which present inside a hyperlink element - Docx4j
I'm trying to replace a text with trackchange which present inside a hyperlink element.
I'm using replacetext_2_0 bookmark for find value. I tried couple of logics but not received the expected output....
2
votes
1
answer
83
views
Docx4j export FO ignores standalone whitespace
I'm using docx4j-export-FO 11.3.2 to convert a docx file into xsl-fo using sample code from here https://github.com/plutext/docx4j-export-FO/blob/master/src/samples/docx4j/org/docx4j/samples/...
0
votes
0
answers
35
views
Loading embedded excel data modified through docx4j directly onto piechart in word document
I've written a program in java in which I take a new xlsx file as an input and add it as the embedded excel file to a piechart in word document. The problem is in the newly generated word document new ...
2
votes
1
answer
133
views
Docx4j variableReplace with styling
I want to creating new Word document from a model document (.docx) and replace some text with styling.
How can I style the firstName in Bold and message as yellow highlight color?
My Code is below:
...
1
vote
2
answers
291
views
Issue loading .XML files with doc4J in Java
I am facing an issue where I cannot load even the sample word2003xml.xml which is provided by doc4J for tests in docx4j-samples-docx4j-8.3.1.zip found here https://www.docx4java.org/downloads.html
I ...
0
votes
0
answers
74
views
How to update fields in main part of docx document with docx4j
I want to automatically update fields such as table or number of pages by docx4j. I know about macros, which could update all fields during opening the document, but word need permission to apply it. ...
0
votes
1
answer
59
views
docx4j / xlsx4j - why does Row ignore cells with an empty value
I'm currently using org.docx4j:docx4j-JAXB-ReferenceImpl:11.2.9 in a project.
While iterating over an Excel sheet, I need to read all the cell values, even the ones that are empty.
File ...
0
votes
0
answers
62
views
Get page count of word document using docx4j
I have following code:
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage()
Tbl tableF = factory.createTbl();
wordprocessingMLPackage.getMainDocumentPart().addObject(...
0
votes
0
answers
56
views
Remove Header from second page docx file using docx4j
Am using docx4j for HTML2Word Convert, here i have added Header and Footer using Docx4j API. Header and Footer is working fine with image and page number. But my problem is i dont want repeated Header ...
0
votes
0
answers
87
views
Not able to create package using docx4j WordprocessingMLPackage in java
Converting a html file or string through docx4j getting an error while running the code
public static void convertHtmltoWord2(String html) {
WordprocessingMLPackage wordMLPackage = ...
0
votes
0
answers
100
views
Problem with footer only first page docx4j
Good morning
I try to create a .docx documento using docx4j.
In the document I need to insert the footer only in the first page.
This is my code
private WordprocessingMLPackage wordMLPackage;
private ...
0
votes
1
answer
97
views
How to add new line in replacement string - Docx4j
I'm using Docx4j with Java/Spring and i've built a service that replaces some placeholders in a document with variable values.
So in my docx I have a "placeholder" like this: [address] that ...
0
votes
1
answer
73
views
Docx4J.toPDF throws PropertyException - No conversion defined
I'm using commercial version of Doc4J, and I'm trying to convert a docx4j generated docx file to pdf using Docx4J.toPDF API. It fails with the below error.
How to fix this issue? Does this colour need ...
0
votes
0
answers
160
views
java.lang.ClassNotFoundException: org.docx4j.jaxb.suninternal.NamespacePrefixMapper -Docx4j
I updated docx4j from 6.1.2 to 8.0.0 version (https://www.docx4java.org/forums/announces/docx4j-8-0-0-released-t2808.html). I'm using docx4j-JAXB-Internal. When I try to execute, I'm getting the ...
3
votes
0
answers
56
views
Issue in wp:docPr while loading the docx file using docx4j
Processed a docx file which contains image using docx4j. After loading the file I logged document part, I found that "title" attribute is missing inside <wp:docPr> element. Let me know ...
0
votes
1
answer
669
views
Outputting Docx4J to PDF File
I am using the commercial version of docx4j and we have a requirement to output the document to PDF format. I understand there are two options. One is to use an online converter tool. The other is to ...
0
votes
0
answers
35
views
docx remains a template file after mail merge with docx4j
Using the examples, I've manage to get my merge fields properly replaced with test data. However, when I open the output file in Word, it still asks for the mailmerge.mer file and the character ...
1
vote
1
answer
191
views
Docx4j export to PDF/A-1b - base14 fonts embedding
I need to export a docx document to PDF/A-1b on a Ubuntu server, using the Apache FOP backend.
The document is nothing fancy, it uses the basic windows fonts Calibri, Courier New, Times New Roman, ...
0
votes
2
answers
145
views
Why I can't do a multipage mail merge?
What I am currently trying is doing a multi page mail merge, the problem is that currently i just overwrite the content with my second map.
This are the important code snippets:
public static void ...
0
votes
1
answer
349
views
Unreadable content error after generating word document from template with docx4j
We have recently been using docx4j for a project that requires generating docx from templates with variable injection. To do this, we had purchased the plutext-enterprise libs to be able to merge of ...
0
votes
3
answers
126
views
How to correctly make a copy of a textfield?
My problem is that i can't get my textfields with document.getContent() and document.getContents().
So I tried to use XPath for selecting the objects, it works but i can't copy the object and add it ...
0
votes
0
answers
457
views
Word found unreadable content in .docx after replacing content through docx4j
I am getting error Word found unreadable content in .docx after replacing content through docx4j.
Please find code snippet.
I am using docx4j-6.1.2 jar
public class Testt {
public static void main(...
0
votes
0
answers
87
views
How to copy textfields to another page?
I have a document with a text field, so my problem is that i don't get any content with document.getContents() or document.getContent()?
Is this a limit from the free version or why I don't get ...
1
vote
1
answer
140
views
Insert line break in docx4j with variable replacement
I have a template with certain variables that I need to replace with info from my database, basically.
when I just want to replace with a word it's easy, my problem is when I need to break line like ...
0
votes
1
answer
456
views
Exporting Doc to PDF makes a Docx4JException
I am trying to export a Doc to PDF, the Document doesn't matter because i get the same error with a blank document.
I'm using docx4j with gradle because i have no experience with maven and i don't ...
1
vote
1
answer
156
views
HTML does not maintain formatting after using docx4j XHTMLImporterImpl
Im currently using XHTMLImporterImpl version 8.0 and docx4j 8.23
I have the current html, saving this to a file and viewing in a browser looks good but after using the conversion, we loose all ...
0
votes
0
answers
136
views
Why does adding w:drawing cause corrupted file
I'm trying to add a chart to a docx file using docx4j. I generated what i wanted in Word and with the help of the docx4j webapp i was able to get the corresponding java code. Unfortunately the ...
0
votes
1
answer
43
views
How do I bind a new footer1.xml to a word document?
I have an already existing word document that has a footer with text. I've found the relationship part that I want to replace and have footer part that I want to replace it with.
From what I ...
0
votes
1
answer
316
views
LinkageError: loader constraint violation - BundleClassLoader - docx4j
Am using org.docx4j.Docx4J in a desktop application (JDK1.8) for converting WORD file to PDF and it all works fine.
The same desktop application, when launched as an OSGi plug-in (JDK1.8), throws ...