0

I am attempting to convert a DOCX file to PDF with Docx4J and receiving two distinct exceptions for two different documents.

1) For document 1, a NullPointerException occurs at org.docx4j.utils.SingleTraversalUtilVisitorCallback.apply(SingleTraversalUtilVisitorCallback.java:27) for the first document.

2) For document 2, this exception occurs: org.apache.fop.fo.ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table."

The content of the documents is similar. Both documents contain tables in them that were created with Apache POI. Tables in both documents contain multi-column cell spans (set by POI). These errors do not occur when no spans are present in Apache POI-created tables. Clearly, the problem has something to do with the spans. I am wondering if I am incorrectly creating spans with POI.

Is the code I have included below the correct way to create cell spans in tables within POI? Another important fact to note, is that, if I open either document in Word one time and save it out (after creating it initially with POI, subsequent PDF conversion is successful. This is an indication to me that Word is cleaning up inconsistency or problems with the document. I want to confirm that the spans are being created correctly to avoid the suspected table problem.

Here's the code I'm using to create the span in the document table with Apache POI:

XWPFTableRow row = table.getRow( rowIndex );
XWPFTableCell cell = row.getCell( colIndex );
CTTcPr cellPointer = cell.getCTTc().getTcPr();
cellPointer.addNewGridSpan();
cellPointer.getGridSpan().setVal( bigIntSpan );

Here's the code I'm using to convert the doc to PDF:

String fileName = "DocName";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load( new java.io.File( fileName + ".docx" ) );

FileOutputStream outputStream = new FileOutputStream( fileName + ".pdf" );

Docx4J.toPDF( wordMLPackage, outputStream );

Here's the full XML from the word/document.xml file in the DOCX archive:

<?xml version="1.0" encoding="UTF-8"?>
<w:document mc:Ignorable="w14 wp14" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" 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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><w:body><w:p w14:paraId="23F196FC" w14:textId="6A07C789" w:rsidR="00224B2C" w:rsidRDefault="00224B2C" w:rsidP="00224B2C"><w:pPr><w:jc w:val="center"/><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:b/></w:rPr><w:t>Event Order Services</w:t></w:r></w:p><w:p w14:paraId="73306DCF" w14:textId="77777777" w:rsidR="00224B2C" w:rsidRDefault="00224B2C"><w:pPr><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="18"/></w:rPr></w:pPr></w:p><w:tbl><w:tblPr><w:tblW w:w="0" w:type="auto"/><w:tblW w:type="dxa" w:w="11000"/><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="none" w:sz="0" w:space="5" w:color="000000"/><w:insideV w:val="single"/></w:tblBorders><w:tblCellMar><w:top w:type="dxa" w:w="40"/><w:left w:type="dxa" w:w="100"/><w:bottom w:type="dxa" w:w="40"/><w:right w:type="dxa" w:w="100"/></w:tblCellMar></w:tblPr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Service Time and Location</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Service Type and Notes</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Service Items</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Quantity</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Price</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders><w:shd w:color="auto" w:val="clear" w:fill="D4D3C9"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="true"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Total</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>5:00pm-7:00pm</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Food</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t xsi:nil="true"/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Breakfast Pastries</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Assorted Breakfast Pastries and Muffins (One Dozen)</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>9.50</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$18.00</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="thick" w:space="0" w:color="000000"/></w:tcBorders></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$171.00</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Chicken Parmesan</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Charcoal Grilled Chicken Breast with Roasted New Potatoes, Pancetta, Mushroom, Chard and Roast Garlic Aioli</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>75</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$9.50</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$712.50</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>5:00pm-7:00pm</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Beverage</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t xsi:nil="true"/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>House Chardonnay</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>55</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$8.50</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$467.50</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Imported Beer</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>75</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$3.00</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>$225.00</w:t></w:r></w:p></w:tc></w:tr><w:tr><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>6:00pm-6:30pm</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="2000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Equipment</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t xsi:nil="true"/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="4000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>Large Trash Cans</w:t></w:r></w:p><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>20 Gallon Trash Cans</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t>8</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:tcPr><w:tcW w:type="dxa" w:w="1000"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcBorders><w:top w:val="none" w:space="0" w:color="FFFFFF"/></w:tcBorders></w:tcPr><w:p><w:pPr><w:jc w:val="center"/></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" w:eastAsia="Arial"/><w:b w:val="false"/><w:i w:val="false"/><w:sz w:val="20"/></w:rPr><w:t/></w:r></w:p></w:tc></w:tr></w:tbl><w:p/><w:p w14:paraId="7C9EC931" w14:textId="64559963" w:rsidR="00946FE4" w:rsidRPr="002C5993" w:rsidRDefault="00516E3A" w:rsidP="006726C4"><w:pPr><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="18"/></w:rPr></w:pPr><w:proofErr w:type="spellStart"/><w:proofErr w:type="gramStart"/><w:r w:rsidR="00F41D65" w:rsidRPr="00F41D65"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="18"/></w:rPr><w:t/></w:r><w:r w:rsidR="00674C75"><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/><w:sz w:val="18"/></w:rPr><w:t/></w:r><w:proofErr w:type="spellEnd"/><w:proofErr w:type="gramEnd"/></w:p><w:p w14:paraId="1046E6B9" w14:textId="3BF4552D" w:rsidR="00FF34DB" w:rsidRPr="001E128D" w:rsidRDefault="00FF34DB" w:rsidP="001E128D"><w:pPr><w:tabs><w:tab w:val="left" w:pos="4507"/></w:tabs><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/></w:rPr></w:pPr><w:bookmarkStart w:id="0" w:name="_GoBack"/><w:bookmarkEnd w:id="0"/></w:p><w:sectPr w:rsidR="00FF34DB" w:rsidRPr="001E128D" w:rsidSect="000E7529"><w:headerReference w:type="even" r:id="rId9"/><w:headerReference w:type="default" r:id="rId10"/><w:footerReference w:type="even" r:id="rId11"/><w:footerReference w:type="default" r:id="rId12"/><w:headerReference w:type="first" r:id="rId13"/><w:footerReference w:type="first" r:id="rId14"/><w:type w:val="continuous"/><w:pgSz w:w="12240" w:h="15840" w:code="1"/><w:pgMar w:top="288" w:right="720" w:bottom="662" w:left="720" w:header="720" w:footer="720" w:gutter="0"/><w:cols w:space="720"/><w:docGrid w:linePitch="272"/></w:sectPr></w:body></w:document>

and the stacktrace:

[2015-01-08 15:05:04,084] [http-bio-7070-exec-10] ERROR [org.docx4j.convert.out.common.AbstractExporter] - Exception exporting package java.lang.NullPointerException at org.docx4j.utils.SingleTraversalUtilVisitorCallback.apply(SingleTraversalUtilVisitorCallback.java:27) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:76) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:78) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:78) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:78) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:78) at org.docx4j.utils.AbstractTraversalUtilVisitorCallback.walkJAXBElements(AbstractTraversalUtilVisitorCallback.java:78) at org.docx4j.TraversalUtil.visit(TraversalUtil.java:662) at org.docx4j.TraversalUtil.visit(TraversalUtil.java:574) at org.docx4j.convert.out.common.preprocess.FieldsCombiner.process(FieldsCombiner.java:59) at org.docx4j.convert.out.common.Preprocess.process(Preprocess.java:144) at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:51) at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:32) at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:63) at org.docx4j.Docx4J.toFO(Docx4J.java:467) at org.docx4j.Docx4J.toPDF(Docx4J.java:481)

Dan Torrey
  • 1,379
  • 15
  • 25
  • 2
    That's a strange one. Perhaps a different JAXB implementation? If you'd like to email me a docx exhibiting the issue, I'll see whether I can replicate it here. Alternatively, we can add some debugging in the method giving the NPE. – JasonPlutext Jan 09 '15 at 02:00
  • Thanks very much for your reply. After further testing with a fresh mind today, I confirmed that the same error occurs in both the console app and in the Tomcat app. If I open the document in Word, save it, then attempt the conversion again, it is successful. I am certain the document is the issue here (not the environment). The doc is manipulated programmatically (tables, text added), with Apache POI before the conversion. I am certain something is not being done correctly when the document is manipulated/changed with POI. – Dan Torrey Jan 09 '15 at 13:21
  • Word is probably cleaning up the problems with the document when it saves it. – Dan Torrey Jan 09 '15 at 13:26
  • After doing more testing, I encountered this exception: org.apache.fop.fo.ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table." This error occurs only when a table is created in the document with POI that has a multi-column span defined in it. – Dan Torrey Jan 09 '15 at 13:43
  • I reworded the question with new information learned about possible incorrect table span creation with Apache POI. – Dan Torrey Jan 09 '15 at 14:02
  • 1
    Can you unzip your docx, navigate to the word/document.xml part, then paste the XML representing the table into your question? Alternatively, you can use the Docx4jHelper Word AddIn to see the XML from within Word. – JasonPlutext Jan 09 '15 at 22:47
  • Hi Jason, I added the XML from the suspected problem table to my question above. Thanks very much for taking a look. – Dan Torrey Jan 12 '15 at 14:28
  • 1
    Sorry for the delay. When I attempt to generate PDF output from a docx containing that table, I don't see that issue (I'm using current docx4j sources, which could be why, or the issue could be elsewhere in your docx). It gets further than that (creates an FO file), but FOP complains "table-layout="fixed" and column-width unspecified => falling back to proportional-column-width(1)" then "ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table." – JasonPlutext Jan 14 '15 at 22:49
  • 1
    I notice you have 2 tblPr elements; there should only be one. And they contain different tblW values. – JasonPlutext Jan 14 '15 at 22:50
  • Hi Jason, Thanks for your reply. I cleaned up the 2 tblPr elements with different widths. After further testing, I identified that the problem was indeed elsewhere in the document. I have updated my question with the full word/document.xml file. I also compiled the latest sources for Docx4J (v3.2.2). The problem still occurs with 3.2.2 sources. I narrowed it down to one problematic table. Only this table is included in the document.xml provided in my question. Would you please be able to take one more look at the document.xml file to see if you can reproduce the problem? Thanks very much. – Dan Torrey Jan 16 '15 at 23:44
  • Hi Jason, Please disregard my last comment left 21 mins ago. I have positively identified the cause of this problem. It turns out that, if an XWPFRun inside a XWPFTableCell > XWPFParagraph has text = null, then this exception occurs. There was a bug in my code that would pass null to xwpfRun.setText(), for some runs in the problematic table. I added a null check here, and subsequent PDF conversion with Docx4J is successful. Woohoo!! Thanks for helping me solve this!! Also, I wonder if defensive code could be added to Docx4j to protect against this condition? Just an idea to consider. – Dan Torrey Jan 17 '15 at 00:11
  • 1
    Great. See now https://github.com/plutext/docx4j/commit/3e2318f31d590c9684d10149a0dcad5cbc5948b9 – JasonPlutext Jan 18 '15 at 00:46

1 Answers1

0

The NullPointerException at org.docx4j.utils.SingleTraversalUtilVisitorCallback.apply(SingleTraversalUtilVisitorCallback.java:27 was caused by an Apache POI XWPFRun that had null text. There was code in my application that would erroneously set the text for an XWPFRun inside a XWPFTableCell > XWPFParagraph element to null.

When the subsequent conversion of the document to PDF was performed, the above-mentioned exception would occur. I added code to make sure no XWPFRuns exist in the document with null text.

Whenever a run is created, now I do it like this to make sure the text can never be null.

xwpfRun.setText( text == null ? "" : text);

I hope this helps anyone else who hits this error.

Dan Torrey
  • 1,379
  • 15
  • 25