Issue 452 in xdocreport: DOCX to PDF

271 views
Skip to first unread message

xdocr...@googlecode.com

unread,
Nov 14, 2014, 3:53:50 PM11/14/14
to xdocr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 452 by tulasi.k...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

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

--
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

Pascal Leclercq

unread,
Nov 17, 2014, 3:35:29 PM11/17/14
to xdocr...@googlegroups.com
Not sure what we can do here.

It looks like more a POI problem which expect an integer for 

BigInteger  headerY = CTSectPr.getPgMar().getHeader();

and your docx document have 720.0.

How do you create/generate your docx ? 



You received this message because you are subscribed to the Google Groups "xdocreport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xdocreport+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Pascal Leclercq

xdocr...@googlecode.com

unread,
Nov 18, 2014, 3:41:03 AM11/18/14
to xdocr...@googlegroups.com
Updates:
Status: Accepted
Owner: angelo.z...@gmail.com

Comment #1 on issue 452 by angelo.z...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

> It looks like more a POI problem which expect an integer for

I agree with you Pascal, but perhaps we could try/catch this error?

@tulasi : please add your docx.

@pascal : it seems that xdocreport users cannot attach document in
xdocreport forum (size of attached document is not enough)

xdocr...@googlecode.com

unread,
Nov 25, 2014, 12:06:10 AM11/25/14
to xdocr...@googlegroups.com

Comment #2 on issue 452 by tulasi.k...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

Thanks for your reply.Can you please tell me how can i attach the document.

xdocr...@googlecode.com

unread,
Nov 25, 2014, 12:18:55 PM11/25/14
to xdocr...@googlegroups.com

Comment #3 on issue 452 by pascal.leclercq: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

I asked again google to increase the quota but It takes time It seems.

As a workaround, can you please try posing your content on the mailing
list ?

https://groups.google.com/forum/#!forum/xdocreport ?

Tulasi Kumar

unread,
Nov 26, 2014, 12:04:47 AM11/26/14
to xdocr...@googlegroups.com, codesite...@google.com, xdocr...@googlecode.com

Code Snippet:                


                        // 1) Load DOCX into XWPFDocument

InputStream is = new FileInputStream(new File(

"docx/Sample.docx"));

BufferedInputStream st=new BufferedInputStream(is);

XWPFDocument document = new XWPFDocument(st);


// 2) Prepare Pdf options

PdfOptions options = null;


// 3) Convert XWPFDocument to Pdf

OutputStream out = new FileOutputStream(new File(

"pdf/Sample.pdf"));

PdfConverter.getInstance().convert(document, out, options);


And attached the document along with same.Can you please help me out and am completely blocked here.

Sample.docx

xdocr...@googlecode.com

unread,
Nov 26, 2014, 4:28:56 AM11/26/14
to xdocr...@googlegroups.com

Comment #4 on issue 452 by angelo.z...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

Hi tulasi,

Your problem is because your docx contains not valid integer.

If you unzip you docx and you see the word/document.xml you can see that
page margin, page size contains dot character :

---------------------------------------------------------------------
<w:sectPr>
<w:pgSz w:w="12240.0" w:orient="portrait" w:h="15840.0"/>
<w:pgMar w:right="1440.0" w:left="1440.0" w:top="1440.0" w:header="720.0"
w:gutter="0" w:footer="720.0" w:bottom="1440.0"/>
</w:sectPr>
---------------------------------------------------------------------

For instance header is "720.0" altough it should have "720".

The problem coes from xmlbeans JavaIntegerHolder lex method
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.xmlbeans/xmlbeans/2.4.0/org/apache/xmlbeans/impl/values/JavaIntegerHolder.java#46

To fix your problem, lex should remove the '.' like this :

---------------------------------------------------------------------
int index = s.indexOf( '.' );
if ( index != -1 )
{
s = s.substring( 0, index );
}
---------------------------------------------------------------------

So I suggest you that you post your problem to POI forum by attaching your
docx and explaining your problem.

Regard's Angelo

xdocr...@googlecode.com

unread,
Nov 26, 2014, 2:31:24 PM11/26/14
to xdocr...@googlegroups.com

Comment #5 on issue 452 by siva.kar...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

Thanks for your reply.I am able to resolve the above exceptions with your
fix.But getting some other exceptions.
java.lang.ExceptionInInitializerError
at
org.openxmlformats.schemas.wordprocessingml.x2006.main.DocumentDocument$Factory.parse(Unknown
Source)
at
org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentRead(XWPFDocument.java:134)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:159)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:123)
at com.word.pdf.wordtopdf.createPDF(wordtopdf.java:62)
at com.word.pdf.wordtopdf.main(wordtopdf.java:20)
Caused by: java.lang.IllegalStateException: Cannot load
getContextTypeLoader: verify that xbean.jar is on the classpath
at org.apache.xmlbeans.XmlBeans.buildMethod(XmlBeans.java:181)
at org.apache.xmlbeans.XmlBeans.buildNoArgMethod(XmlBeans.java:190)
at
org.apache.xmlbeans.XmlBeans.buildGetContextTypeLoaderMethod(XmlBeans.java:200)
at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:126)
... 6 more
Caused by: java.lang.ClassNotFoundException:
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at org.apache.xmlbeans.XmlBeans.buildMethod(XmlBeans.java:174)
... 9 more

Are you able to convert the provided docx to pdf.

xdocr...@googlecode.com

unread,
Nov 26, 2014, 3:21:01 PM11/26/14
to xdocr...@googlegroups.com

Comment #6 on issue 452 by angelo.z...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

It's a problem with POI. Please post your question to POI forum.

Thank's

xdocr...@googlecode.com

unread,
Nov 27, 2014, 1:07:33 AM11/27/14
to xdocr...@googlegroups.com

Comment #7 on issue 452 by tulasi.k...@gmail.com: DOCX to PDF
https://code.google.com/p/xdocreport/issues/detail?id=452

Thanq so much for all your help.Can you please provide me POI forum link.I
didn't find proper link from google.
Reply all
Reply to author
Forward
0 new messages