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

Docx4j is a Java library for manipulating Microsoft OpenXML files (Word docx, Powerpoint pptx, and Excel xlsx). It uses JAXB to create the in-memory representation.

It is similar to Microsoft's OpenXML SDK, but for Java. docx4j uses JAXB to create the in-memory object representation.

It is available under the Apache License (v2).

docx4j was created by Plutext Pty Ltd in 2008 - using OpenXML4J for the OPC piece. Plutext still drives the project, but since then docx4j has benefited from contributions from many individuals. The contributors are listed in docx4j's pom.xml.

The docx4j online demo is available here.

911 questions
3
votes
1 answer

Generate .docx from HTML with Base64 images with docx4j

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.…
FranciscoBouza
  • 590
  • 6
  • 19
3
votes
1 answer

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

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…
Anup Ganatra
  • 366
  • 1
  • 6
  • 23
3
votes
1 answer

org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships'

I have been trying different things with content controls and docx4j. I added/removed couple of controls and now docx4j wont load the document anymore. Getting this error ar runtime. org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add…
Artin
  • 745
  • 1
  • 7
  • 14
3
votes
0 answers

How to populate a template docx or odt in android with library?

I'm making an android app and I want to fill a table template inserted in to a docx document. I'm trying the XdocReport library but I can't accomplish. I also read about JODRreports and Docx4j but I don't find info about using on Android. Other…
pablogupi
  • 774
  • 11
  • 27
3
votes
1 answer

How to get values from Ms word merge field using Docx4j Java

I am trying to retrieve value from merge field using Docx4j in java. Currenty I'm retrieving all the contents of the word document using: WordprocessingMLPackage newWordMLPackage = WordprocessingMLPackage .load(new…
Sujal
  • 671
  • 1
  • 16
  • 34
3
votes
1 answer

How to replace text/Merge field in Ms word with docx4j

I am trying to replace text or merge field from word document. I found out that I could use docx4j for this purpose. String docxFile = "C:/Users/admin/Desktop/HelloWorld.docx"; WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage …
Sujal
  • 671
  • 1
  • 16
  • 34
3
votes
4 answers

docx4j find and replace

I have docx document with some placeholders. Now I should replace them with other content and save new docx document. I started with docx4j and found this method: public static List getAllElementFromObject(Object obj, Class toSearch) { …
luckyi
  • 465
  • 2
  • 6
  • 9
3
votes
1 answer

Blue color table border using docx4j

I'm using docx4j to create a docx file. I want my table border to be blue colored but it is only showing black.how to do this? Here is my code: table.setTblPr(new TblPr()); CTBorder border = new CTBorder(); …
3
votes
1 answer

Create new paragraph with Docx4j

I'm having problem creating a Paragraph with docx4j. Well, actually not the paragraph itself, but it's contents. I'm putting together a new document from paragraphs (actually "blocks" made of paragraphs) and everything is working fine. I'm appending…
omniflash
  • 191
  • 1
  • 14
3
votes
1 answer

read, replace placeholders and write a word file with docx4j

I have a Word File look like this: You don't need to understand the content, just take a look to my placeholders and . There are 10 pages with these placeholders and now I should replace them with other content. The…
user1722476
3
votes
1 answer

IE does not open "application/vnd.openxmlformats-officedocument.wordprocessingml.document"

I have a spring mvc application that returns *.docx files (generated using docx4j). I send them to the browser with content type "application/vnd.openxmlformats-officedocument.wordprocessingml.document". This works as intended in firefox, chrome,…
jschneeberger
  • 41
  • 1
  • 1
  • 3
3
votes
1 answer

Docx4j library is not thread-safe. What are possible ways to workaround this issue?

I have wrote an application that must parse and retrieve some data from a few thousands large docx files. It will run on a high-performance production server with many CPUs, large amount of RAM and fast SSDs in RAID arrays, so obviously I want to…
user1764823
  • 425
  • 2
  • 8
  • 16
3
votes
1 answer

For some cases, convert XHTML to docx with docx4j lose original style

during my test, I find when converting following html content to docx, the original style will be lost. < a href="http://www.google.com">Google< /a> result in docx: no underline. < p>< span style="text-decoration: underline;">underline text<…
3
votes
4 answers

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

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)?
user2211381
  • 31
  • 1
  • 2
  • 3
3
votes
1 answer

How to get Page/Sheet Count of Word/Excel documents?

In my project I have one requirement to show the number of pages in Word documents (.doc, .docx) files and number of sheets in Excel documents (.xls, .xlsx). I have tried to read the .docx file using Docx4j but the performance is very poor but I…
user1805885