Issue 239 in xdocreport: NPE when generating pdf from docx at XWPFDocumentVisitor.java:453

376 views
Skip to first unread message

xdocr...@googlecode.com

unread,
Mar 26, 2013, 7:29:11 AM3/26/13
to xdocr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 239 by kovacsat...@gmail.com: NPE when generating pdf from docx
at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

What steps will reproduce the problem?
PDF generation

What is the expected output? What do you see instead?
PDF document. NPE.

What version of the product are you using? On what operating system?
1.0.0. Win7

Please provide any additional information below.

Conversion of the attached document Doc1.docx (having only 4 lines: a
title, a subtitle, a section title, and a normal line) results in NPE (see
below). However, when removing the subtitle, the conversion will be
successful, but the section title will be indented (see Doc1.pdf).

I've just read the article about the conversion of JODConverter, docx4j and
XDocReport
(http://angelozerr.wordpress.com/2012/12/06/how-to-convert-docxodt-to-pdfhtml-with-java/)
and wanted to test your software before making decision about using it in
our product for docx to pdf conversion. However, I wasn't able to convert
the first simple document, moreover the second try (without subtitle)
resulted in major formatting change. Would you please investigate the NPE
and formatting issues? Is there any information about the limitations of
XDocReport usage?

Best regards,
Attila


org.apache.poi.xwpf.converter.core.XWPFConverterException:
java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:59)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:37)
at
org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
... 4 more
Caused by: java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.getXWPFNum(XWPFDocumentVisitor.java:453)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.getNumPr(XWPFDocumentVisitor.java:326)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitParagraph(XWPFDocumentVisitor.java:271)
... 9 more

Attachments:
Doc1.docx 14.6 KB
Doc1.pdf 32.1 KB

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

xdocr...@googlecode.com

unread,
Mar 26, 2013, 10:16:27 AM3/26/13
to xdocr...@googlegroups.com
Updates:
Status: Fixed
Owner: angelo.z...@gmail.com

Comment #1 on issue 239 by angelo.z...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

Hi Attila,

At first thank's to have attaching your docx. I have add it in your JUNit
https://code.google.com/p/xdocreport/source/browse/#git%2Fthirdparties-extension%2Forg.apache.poi.xwpf.converter.pdf%2Fsrc%2Ftest%2Fresources%2Forg%2Fapache%2Fpoi%2Fxwpf%2Fconverter%2Fcore
(see Issue239.docx).

I have fixed your 2 problems and commit on Git :

1) problem with NPE (see
https://code.google.com/p/xdocreport/source/detail?r=3bb48debd9cf3ef9ba7ad8810932c88a9ba0700a).
Your docx is strange because you have not numId for your numPr (first time
I see that), I have checked that numId is not null.
2) problem with indentation is fixed (the paragraph properties overrides
the numbering level properties ofr indentation).

Thoses fixes will available for 1.0.1

> Is there any information about the limitations of XDocReport usage?
It's very difficult to do that because docx are very very hard format and
we fix problems when users attach (like you) problems.

But today limitations are :

* shapes (wich are drawn) are not converted.
* have some bugs with tab stop.
* table border should be improved.

If you find bugs, don't hesitate to create issue and attache your (simply
docx).

Regards Angelo

xdocr...@googlecode.com

unread,
Mar 26, 2013, 12:02:21 PM3/26/13
to xdocr...@googlegroups.com

Comment #2 on issue 239 by kovacsat...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

Hi Angelo,

Thanks for the very quick reply/solution.

I've just found another issue. The height of page body of the generated pdf
is higher than the one of the source docx in such a way that the page body
and the footer are overlapped. I've attached the docx. The source document
has 2 pages: on the 2nd page there are 2 lines. The generated pdf has only
1 page and the lines from the 2nd page of the original docx appear in the
footer of the first page of pdf.

I can imagine that working with docx format may be very strange, so I can
accept minor format differences between the input and output. However, it
is a requirement for us that the pages of the original docx must match with
the pages of the generated pdf. Namely, page x of pdf must contain the
content of page x of docx. We have contracts in docx that can be modified
until a certain step of our process flow and after a point it should be
converted to pdf (that cannot be modified afterwards). Would you please
investigate this issue as well?

xdocr...@googlecode.com

unread,
Mar 26, 2013, 12:33:08 PM3/26/13
to xdocr...@googlegroups.com

Comment #3 on issue 239 by angelo.z...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

> Thanks for the very quick reply/solution.
You are welcome

> I've just found another issue.
Please create a new issue with your attached docx you have not attached
your docx).

You must understand that we develop XDocReport on our spare time, so I
cannot promise you that I will fix your problem as soon as possible.

Our PDF converter is not perfect and I think you will find several
problems. But with docx4j and JODConverter you will find problems too.
Developping PDF converter is very hard, so I think you will not find a
perfect PDF converter (I have tested too payed product and they have too
problems)

Page number is not managed for docx (but our PDF->ODT converter manages
that, I must see how it manages that).

Regards Angelo

xdocr...@googlecode.com

unread,
Oct 17, 2013, 4:46:18 PM10/17/13
to xdocr...@googlegroups.com

Comment #4 on issue 239 by amitabh....@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

I am also facing same issue even though I am using jars of version 1.0.2

xdocr...@googlecode.com

unread,
Oct 18, 2013, 3:01:40 AM10/18/13
to xdocr...@googlegroups.com

Comment #5 on issue 239 by angelo.z...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

This issue fixes NPE with the attached Doc1.docx. If you have a problem
with NPE, please attach your docx.

xdocr...@googlecode.com

unread,
Dec 24, 2013, 3:37:42 AM12/24/13
to xdocr...@googlegroups.com

Comment #6 on issue 239 by c.ya...@gmail.com: NPE when generating pdf from
docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

I am getting the same NPE, i am using jars of version 1.0.3



Attachments:
test1.docx 335 KB

xdocr...@googlecode.com

unread,
Dec 24, 2013, 7:48:46 AM12/24/13
to xdocr...@googlegroups.com

Comment #7 on issue 239 by angelo.z...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

Have you tried with 1.0.4 SNPASHOT?

If you have the same problem, I will try to fix it when I will find time.

Regards Angelo

Rohit Patel

unread,
Feb 24, 2014, 6:16:48 AM2/24/14
to xdocr...@googlegroups.com, codesite...@google.com, xdocr...@googlecode.com
it still give error............
 

xdocr...@googlecode.com

unread,
Jun 13, 2014, 11:12:31 AM6/13/14
to xdocr...@googlegroups.com

Comment #8 on issue 239 by jose.mar...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

Hi guys,


I'm facing a related problem.

- I generated a .docx (recibo.docx) file using Apple Pages (I don't have
the Microsoft Word software here), and as so the document is possibly not
100% compliant.

- Using one of the samples (DocxProjectWithVelocity2PDF.java) as a
reference, I tried to generate a .pdf file.

- I got the NPE at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.getXWPFNum( CTNumPr
numPr ) because my "document.numbering" is null!

- Tried to add a page number (at the footer or somewhere else in the
document) and the problem persists.

- So, for the people that can't build a proper .docx
document, "document.numbering == null" is a issue!

And last but no least, I'm using the 1.0.4 XDocReport version.

Attachments:
recibo.docx 481 KB
DocxProjectWithVelocity2PDF.java 9.8 KB
Recibo.java 250 bytes

xdocr...@googlecode.com

unread,
Jun 13, 2014, 11:19:25 AM6/13/14
to xdocr...@googlegroups.com

Comment #9 on issue 239 by angelo.z...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
http://code.google.com/p/xdocreport/issues/detail?id=239

Hi Jose,

Thank's for your clarification.

Could you please attach your docx which causes the problem please. I have
tried to convert your recibo.docx with our online demo
http://xdocreport-converter.opensagres.cloudbees.net/ and it works.

Thank's

xdocr...@googlecode.com

unread,
Nov 14, 2014, 3:37:07 PM11/14/14
to xdocr...@googlegroups.com

Comment #10 on issue 239 by tulasi.k...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
https://code.google.com/p/xdocreport/issues/detail?id=239

hi guys,
i am unable to convert

xdocr...@googlecode.com

unread,
Nov 14, 2014, 3:42:38 PM11/14/14
to xdocr...@googlegroups.com

Comment #11 on issue 239 by tulasi.k...@gmail.com: NPE when generating pdf
from docx at XWPFDocumentVisitor.java:453
https://code.google.com/p/xdocreport/issues/detail?id=239

Hi guys,
i am unable to convert the attached docx into pdf and am using latest 1.0.4
libraries.Please suggest this.

Error:
org.apache.poi.xwpf.converter.core.XWPFConverterException:
org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: Invalid
integer value: 720.0
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:59)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:37)
at
org.apache.poi.xwpf.converter.core.AbstractXWPFConverter.convert(AbstractXWPFConverter.java:45)
at com.word.pdf.wordtopdf.createPDF(wordtopdf.java:37)
at com.word.pdf.wordtopdf.main(wordtopdf.java:18)
Caused by: org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException:
Invalid integer value: 720.0
at
org.apache.xmlbeans.impl.values.XmlObjectBase$ValueOutOfRangeValidationContext.invalid(XmlObjectBase.java:285)
at
org.apache.xmlbeans.impl.values.JavaIntegerHolder.lex(JavaIntegerHolder.java:50)
at
org.apache.xmlbeans.impl.values.JavaIntegerHolderEx.set_text(JavaIntegerHolderEx.java:40)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1135)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1274)
at
org.apache.xmlbeans.impl.values.JavaIntegerHolder.bigIntegerValue(JavaIntegerHolder.java:58)
at
org.apache.xmlbeans.impl.values.XmlObjectBase.getBigIntegerValue(XmlObjectBase.java:1504)
at
org.openxmlformats.schemas.wordprocessingml.x2006.main.impl.CTPageMarImpl.getHeader(Unknown
Source)
at
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.visitHeader(PdfMapper.java:180)
at
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.visitHeader(PdfMapper.java:112)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitHeaderRef(XWPFDocumentVisitor.java:1098)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.visitHeadersFooters(MasterPageManager.java:213)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.addSection(MasterPageManager.java:180)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.compute(MasterPageManager.java:127)
at
org.apache.poi.xwpf.converter.core.MasterPageManager.initialize(MasterPageManager.java:90)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:227)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:194)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 4 more


Regards,
Kumar
Reply all
Reply to author
Forward
0 new messages