Issue 336 in xdocreport: Error converting PDF

1,439 views
Skip to first unread message

xdocr...@googlecode.com

unread,
Nov 27, 2013, 5:56:16 AM11/27/13
to xdocr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 336 by timopra...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

What steps will reproduce the problem?
1. using code:
private static void createPDF() {
try {
long start = System.currentTimeMillis();

// 1) Load DOCX into XWPFDocument
InputStream is = new FileInputStream(new File(
"temp.docx"));
XWPFDocument document = new XWPFDocument(is);

// 2) Prepare Pdf options
PdfOptions options = PdfOptions.create();

// 3) Convert XWPFDocument to Pdf
OutputStream out = new FileOutputStream(new File(
"temp.pdf"));
PdfConverter.getInstance().convert(document, out, options);

System.err.println("Generate pdf/HelloWorld.pdf with "
+ (System.currentTimeMillis() - start) + "ms");

} catch (Throwable e) {
e.printStackTrace();
}
}
2. Using the File as attached
3.

What is the expected output? What do you see instead?
- Expectiing: Generate pdf/HelloWorld.pdf with

- But getting the stacktrace:
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)
at various.testklasse.createPDF(testklasse.java:37)
at various.testklasse.main(testklasse.java:19)
Caused by: java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.getGridColList(XWPFTableUtil.java:166)
at
org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:99)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitTable(XWPFDocumentVisitor.java:827)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:245)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:193)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 4 more

What version of the product are you using? On what operating system?
1.0.3

Please provide any additional information below.
- The File was generated by POI Apache 3.9
- I loaded this File into Windows 2013 on my Windows 8.1 System and saved
it again. Now the converting works, seems Windows is adding something right
which is not important for word.

I hope you can help.


Attachments:
temp.docx 33.8 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,
Nov 27, 2013, 6:08:15 AM11/27/13
to xdocr...@googlegroups.com

Comment #1 on issue 336 by timopra...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

i forgot to add, that the same error happens when using
the 'just-generated' XWPFDocument not like here a loaded file...

xdocr...@googlecode.com

unread,
Nov 27, 2013, 8:13:41 AM11/27/13
to xdocr...@googlegroups.com
Updates:
Status: Accepted
Owner: angelo.z...@gmail.com

Comment #2 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

Thank's for your attached docx. I will see your problem when I will have
time.

Regards Angelo

xdocr...@googlecode.com

unread,
Dec 28, 2013, 5:14:09 PM12/28/13
to xdocr...@googlegroups.com

Comment #3 on issue 336 by rtejad...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

when I use xdoc-report (the same method of the first post) happend:

code error:

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)
at pe.edu.rpanaque.docxsunarppdf.ConvertDocx1.main(ConvertDocx1.java:30)
Caused by: java.lang.NullPointerException
at
org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.getGridColList(XWPFTableUtil.java:166)
at
org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:99)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitTable(XWPFDocumentVisitor.java:827)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:245)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:193)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 3 more


- Also I share you my word document

I have a question:
Why my pdf document has more pages than my word document?
How I can control this behavior?
How I can rewrite the method
"PdfConverter.getInstance().convert(document, out, options);"
to set a standard PDF/A?




Attachments:
docx.docx 192 KB
convert.pdf 81.4 KB

xdocr...@googlecode.com

unread,
Dec 28, 2013, 5:16:20 PM12/28/13
to xdocr...@googlegroups.com

Comment #4 on issue 336 by rtejad...@gmail.com: Error converting PDF
....
thanks a lot.

xdocr...@googlecode.com

unread,
Dec 28, 2013, 5:58:56 PM12/28/13
to xdocr...@googlegroups.com

Comment #5 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

I will see your problem when I will have time.

> Why my pdf document has more pages than my word document?
Our converter si not perfect, so you can have this problem (or perhaps it's
a problem of font that you have not on your computer?).

> How I can control this behavior?
You cannot, the page od pdf is managed by iText. Our converter must be
improved, but it's very hard.

> to set a standard PDF/A?
This feature is available for 1.0.4 (you can use the 1.0.4 snapshot with
maven). Please read
https://groups.google.com/forum/#!searchin/xdocreport/IPdfWriterConfiguration/xdocreport/xgarPynztF8/gH7s0RasxdoJ

xdocr...@googlecode.com

unread,
Dec 30, 2013, 4:35:47 PM12/30/13
to xdocr...@googlegroups.com

Comment #6 on issue 336 by mcama...@inspirait.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

hi angelo, can you help me?

i need add font styles for embed into out file
with PDF/A conformance level, because my word document
contains fonts different a default fonts of the iText.

thanks all.

xdocr...@googlecode.com

unread,
Dec 30, 2013, 4:54:20 PM12/30/13
to xdocr...@googlegroups.com

Comment #7 on issue 336 by mario...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

hi angelo,
i have a problem with the standard PDF/A,
when i export my document to pdf print the
next error:
_______________________
org.apache.poi.xwpf.converter.core.XWPFConverterException:
org.apache.poi.xwpf.converter.core.XWPFConverterException:
com.lowagie.text.DocumentException:
com.lowagie.text.pdf.PdfXConformanceException: All the fonts must be
embedded. This one isn't: Helvetica
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 pe.edu.rpanaque.docxsunarppdf.ConvertDocx1.main(ConvertDocx1.java:40)
Caused by: org.apache.poi.xwpf.converter.core.XWPFConverterException:
com.lowagie.text.DocumentException:
com.lowagie.text.pdf.PdfXConformanceException: All the fonts must be
embedded. This one isn't: Helvetica
at
org.apache.poi.xwpf.converter.pdf.internal.elements.StylableDocument.flushTable(StylableDocument.java:349)
at
org.apache.poi.xwpf.converter.pdf.internal.elements.StylableDocument.close(StylableDocument.java:160)
at
org.apache.poi.xwpf.converter.pdf.internal.PdfMapper.endVisitDocument(PdfMapper.java:170)
at
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:196)
at
org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 3 more
Caused by: com.lowagie.text.DocumentException:
com.lowagie.text.pdf.PdfXConformanceException: All the fonts must be
embedded. This one isn't: Helvetica
at com.lowagie.text.pdf.PdfDocument.add(Unknown Source)
at com.lowagie.text.Document.add(Unknown Source)
at
fr.opensagres.xdocreport.itext.extension.ExtendedDocument.add(ExtendedDocument.java:114)
at
org.apache.poi.xwpf.converter.pdf.internal.elements.StylableDocument.flushTable(StylableDocument.java:345)
... 7 more
Caused by: com.lowagie.text.pdf.PdfXConformanceException: All the fonts
must be embedded. This one isn't: Helvetica
at
com.lowagie.text.pdf.internal.PdfXConformanceImp.checkPDFXConformance(Unknown
Source)
at com.lowagie.text.pdf.PdfWriter.addSimple(Unknown Source)
at com.lowagie.text.pdf.PdfContentByte.setFontAndSize(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.writeLineToContent(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfPRow.writeCells(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(Unknown Source)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(Unknown Source)
at com.lowagie.text.pdf.ColumnText.goComposite(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.addPTable(Unknown Source)
... 11 more
________________________________________________

thanks all

xdocr...@googlecode.com

unread,
Dec 30, 2013, 5:55:50 PM12/30/13
to xdocr...@googlegroups.com

xdocr...@googlecode.com

unread,
Dec 30, 2013, 6:37:35 PM12/30/13
to xdocr...@googlegroups.com

Comment #9 on issue 336 by mario...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

i need add font styles for i have convert docx to pdf/a

xdocr...@googlecode.com

unread,
Dec 30, 2013, 6:48:57 PM12/30/13
to xdocr...@googlegroups.com

Comment #10 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

I cannot help you more, because never played with PDF/A.

It should be cool if some iText user could help us with this toipc.

Thank's

xdocr...@googlecode.com

unread,
Dec 30, 2013, 7:10:19 PM12/30/13
to xdocr...@googlegroups.com

Comment #11 on issue 336 by mario...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

yes, It would be cool .
but you think that you can migrate your project to itext 5.4
,because in this itext's version exists support for the standard pdf/a

thank's.

xdocr...@googlecode.com

unread,
Dec 30, 2013, 7:14:31 PM12/30/13
to xdocr...@googlegroups.com

Comment #12 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

We have choosen to use iText 2.3.7 for the license. Today we have not the
intention (and not the time) to migrate to 5.4.

xdocr...@googlecode.com

unread,
Dec 30, 2013, 7:27:14 PM12/30/13
to xdocr...@googlegroups.com

Comment #13 on issue 336 by mario...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

and if I change itext for FOP or PDFBox its possible?

xdocr...@googlecode.com

unread,
Dec 31, 2013, 3:00:55 AM12/31/13
to xdocr...@googlegroups.com

Comment #14 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

Our PDF converter is based on iText 2.3.7 so you cannot change it for FOP
or PDFBox.
We have started a long time an implementation with FOP but we have gaven it
(very slowly, hard to maintain because of XSL, problem with memory, etc).
For PDFBox I don"t know how to create a PDF from scratch. See issues at
https://code.google.com/p/xdocreport/issues/detail?id=33

xdocr...@googlecode.com

unread,
Dec 31, 2013, 2:29:20 PM12/31/13
to xdocr...@googlegroups.com

Comment #15 on issue 336 by rtejad...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

Hello,
When I'm creating a table with apache poi(poi-3.9-20121203.jar):

XWPFTable table = new XWPFDocument().createTable();

System.out.println(table.getCTTbl());

<xml-fragment
xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
<w:tblPr>
<w:tblW w:w="0" w:type="auto"/>
<w:tblBorders>
<w:top w:val="single"/>
<w:left w:val="single"/>
<w:bottom w:val="single"/>
<w:right w:val="single"/>
<w:insideH w:val="single"/>
<w:insideV w:val="single"/>
</w:tblBorders>
</w:tblPr>
<w:tr>
<w:tc>
<w:p>
<w:r>
<w:t>Hello</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p>
<w:r>
<w:t>World</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr>
<w:tc>
<w:p>
<w:r>
<w:t>This is</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:p>
<w:r>
<w:t>a table</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</xml-fragment>

******It does not create the xml tag
<w:tblGrid>
<w:gridCol w:w="4360"/>
<w:gridCol w:w="4360"/>
..........
..........
</w:tblGrid>

******* I think this could work so:

indexTable =0; //model existing table in the document, template
CTTblPr ct = document.getTables().get(indexTable).getCTTbl().getTblPr();
table.getCTTbl().setTblPr(ct);

CTTblGrid ctg =document.getTables().get(indexTable).getCTTbl().getTblGrid();
table.getCTTbl().setTblGrid(ctg);

thanks.

Attachments:
documentTableCreatePOI.xml 3.6 KB
HELLO.docx 13.5 KB

xdocr...@googlecode.com

unread,
Jan 1, 2014, 3:14:47 PM1/1/14
to xdocr...@googlegroups.com

Comment #16 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

Ok thank's for this info. If I remember w:tblGrid is important to know
width of table, etc. But no time for the moment to fix that-(

xdocr...@googlecode.com

unread,
Jan 5, 2014, 11:08:34 AM1/5/14
to xdocr...@googlegroups.com

Comment #17 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

Hi rtejadapa,

Have you tried to convert your docx with 1.0.4-SNAPSHOT? I have tested your
docx and it works well with 1.0.4-SNAPSHOT.

Regards Angelo

xdocr...@googlecode.com

unread,
Feb 18, 2014, 6:11:48 AM2/18/14
to xdocr...@googlegroups.com

Comment #18 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

I close this issue because none answer.

xdocr...@googlecode.com

unread,
Feb 18, 2014, 6:12:48 AM2/18/14
to xdocr...@googlegroups.com
Updates:
Status: Fixed

Comment #19 on issue 336 by angelo.z...@gmail.com: Error converting PDF
http://code.google.com/p/xdocreport/issues/detail?id=336

1.0.4 seems fix the problem.
Reply all
Reply to author
Forward
0 new messages