docx4j

How to copy a paragraph of .docx to another .docx with Java and retain the style

只愿长相守 提交于 2019-12-30 05:01:08
问题 I am trying to copy the content from a particular paragraph in a .docx to another empty .docx .the problem i have is that the style,bullets,numbering etc from the source.docx is not retained in the destination .docx.Here is my code can anyone please tell me what are the changes to be added to the above code? Thanks in Advance!! public class WordFinal { public static void main(String[] args) throws IOException, XmlException { XWPFDocument doc = new XWPFDocument(new FileInputStream("source.docx

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

为君一笑 提交于 2019-12-29 08:56:11
问题 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 need just the word count and tried using Apache POI. I am getting an error, something like: "trouble writing output: Too many methods: 94086; max is 65536. By package:" I want to know whether there is any paid/open source library available for android

Unable to resize the image while converting html to doc using doc4j

╄→гoц情女王★ 提交于 2019-12-25 09:16:42
问题 I am trying to generate the document from html using docx4j 3.3.1. I am facing below issue can some one help me on these? HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" lang="en"> <head> <title>MonthlyReport</title> <style> table { border:double #000; table-layout: fixed; vertical-align:

Content control toolkit creates extra custom xml parts on reopen docx

随声附和 提交于 2019-12-25 08:32:40
问题 I am creating a docx with 2 rich text controls and 1 picture control. I open content control toolkit, create 1 custom xml part, type in the xml and bind xml tags to the content controls. I save the mapping and close it. When I reopen the docx, I see 3 custom xml parts created. All 3 with all the content controls. I am surprised why it would do that. As a result, when I apply the bindings using docx4j API, the data gets updated in the last custom xml part. Guess the output docx only shows the

docx4j with weblogic Bad [Content_Types].xml Exception

爱⌒轻易说出口 提交于 2019-12-25 06:38:00
问题 how to solve this Exception when I use docx4j with weblogic to open docx file. follow is my code: WordprocessingMLPackage templatePackage = WordprocessingMLPackage .load(getDocxInputTream()); Exception is : 2013-04-03 18:10:29 ERROR ContentTypeManager:698 - java.lang.NullPointerException org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:699) at org.docx4j

How to set Font size and font family in document using docx4j

▼魔方 西西 提交于 2019-12-25 01:44:03
问题 FileReader fr=new FileReader("E://HtmlToDoc//LETTER.html" ); BufferedReader br=new BufferedReader(fr); while( (s=br.readLine())!= null ){ html=html+s;} html="<html><body>"+html.substring(html.indexOf("<body>")); /************************ Setting Page Size **********************************/ Docx4jProperties.getProperties().setProperty("docx4j.PageSize", "B4JIS"); String papersize= Docx4jProperties.getProperties().getProperty("docx4j.PageSize", "B4JIS"); String landscapeString =

DOCX to good quality PNG conversion using docx4j in java

孤人 提交于 2019-12-24 21:23:19
问题 I am trying to convert a .docx document into a .png file using Docx4j in java , and achieved the conversion using the piece of code below. However, the output png file is not of good quality, the text is quite hazy, especially for the images that were present inside the docx file as a part of the document page. I want to improve the quality of the generated image, for that, I tried using the docx.properties file and increase the DPI, but it did not have any effect. WordprocessingMLPackage

set/unset checkbox value with docx4j in MS Word document

浪尽此生 提交于 2019-12-24 21:06:48
问题 I'm trying to set/unset checkbox value with docx4j in MS Word document. Using code from this post: docx4j checking checkboxes I received following XML of this element from my document: <w:fldChar w:fldCharType="begin" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:ns21="urn:schemas-microsoft-com:office:powerpoint" xmlns:ns23="http://schemas.microsoft.com/office/2006/coverPageProps" xmlns:dsp="http:/

How to accept revisions / track changes (ins/del) in a docx?

Deadly 提交于 2019-12-24 19:17:10
问题 In MS-Word 2010 there is an Option under File -> Information to check the document for problems before sharing it. This makes it possible to handle track changes (to new newest version) and remove all comments and annotations from the document at once. Is this possibility available in docx4j as well or do I need to investiagte the corresponding JAXB-Objects and write a traverse finder? Doing that manually could be a lot of work since I would have to add the RunIns ( w:ins ) to the R ( w:r )

How to force Docx4j to refresh a replaced image file

杀马特。学长 韩版系。学妹 提交于 2019-12-24 18:57:58
问题 I use Docx4j to generate various documents and I have a problem with the generation of documents containing images. My program constructs a PNG file with a size of 300x200 pixels and generates a document that contains this image. When I open this document, the image is scaled at 1:1. Then the program overwrites the PNG with an image of 600x400 pixels and generates the document again. When I open this new document, the image is scaled at 1:2. Its dimensions are the same than the previous image