I am trying to covert docx file to pdf in java using docx4j library v3.2.1, I've been following the example given here . I am able to convert the document successsfully but it's missing the image which I've put in header of my word file.
I tried the same docx file with the webapp of docx4j to convert to PDF here, and it gives me the expected result with image.
Logs are as below.
<Feb 12, 2015 11:27:17 AM IST> <Error> <org.docx4j.model.images.WordXmlPictureE20> <BEA-000000> <pic missing!!>
<Feb 12, 2015 11:27:17 AM IST> <Error> <org.docx4j.model.images.WordXmlPictureE20> <BEA-000000> <pic missing!!>
<Feb 12, 2015 11:27:17 AM IST> <Error> <org.docx4j.model.images.WordXmlPictureE20> <BEA-000000> <<ns0:bar xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:ns0="foo" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="1029307" cy="964975"/>
<wp:effectExtent l="19050" t="0" r="0" b="0"/>
<wp:docPr id="2" name="Picture 1" descr="user_image.png"/>
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks noChangeAspect="true"/>
</wp:cNvGraphicFramePr>
<a:graphic>
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="user_image.png"/>
<pic:cNvPicPr/>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId1"/>
<a:stretch>
<a:fillRect/>
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0"/>
<a:ext cx="1029307" cy="964975"/>
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst/>
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</ns0:bar>>
<Feb 12, 2015 11:27:17 AM IST> <Error> <org.docx4j.XmlUtils> <BEA-000000> <java.lang.NullPointerException
javax.xml.transform.TransformerException: java.lang.NullPointerException
UPDATE
I am having a header in my word doc which contains 3X3 table. In that table only second row is filled with data, first and last row are empty. In second row first column in text data, second column contains image and third column is text data. Upon unzipping the docx file I got three header.xml file.
Here by I am attaching header2.xml as it has the data.
Header2.xml
<?xml version="1.0" encoding="UTF-8"?>
<w:hdr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:tbl>
<w:tblPr>
<w:tblStyle w:val="TableGrid" />
<w:tblW w:w="0" w:type="auto" />
<w:tblBorders>
<w:top w:val="none" w:sz="0" w:space="0" w:color="auto" />
<w:left w:val="none" w:sz="0" w:space="0" w:color="auto" />
<w:bottom w:val="none" w:sz="0" w:space="0" w:color="auto" />
<w:right w:val="none" w:sz="0" w:space="0" w:color="auto" />
<w:insideH w:val="none" w:sz="0" w:space="0" w:color="auto" />
<w:insideV w:val="none" w:sz="0" w:space="0" w:color="auto" />
</w:tblBorders>
<w:tblLook w:val="04A0" />
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w="3672" />
<w:gridCol w:w="3672" />
<w:gridCol w:w="3672" />
</w:tblGrid>
<w:tr w:rsidR="006D65A1" w:rsidTr="00412C93">
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:jc w:val="center" />
</w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:tc>
</w:tr>
<w:tr w:rsidR="006D65A1" w:rsidRPr="00FC69E2" w:rsidTr="00412C93">
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:jc w:val="center" />
<w:rPr>
<w:b />
<w:i />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
</w:pPr>
</w:p>
<w:p w:rsidR="006D65A1" w:rsidRDefault="00412C93" w:rsidP="00A07653">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:spacing w:line="276" w:lineRule="auto" />
<w:jc w:val="center" />
<w:rPr>
<w:b />
<w:i />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b />
<w:i />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
<w:t>Left side block</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00412C93" w:rsidRPr="00412C93" w:rsidRDefault="00412C93" w:rsidP="00A07653">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:spacing w:line="276" w:lineRule="auto" />
<w:jc w:val="center" />
<w:rPr>
<w:sz w:val="18" />
<w:szCs w:val="18" />
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00412C93">
<w:rPr>
<w:sz w:val="18" />
<w:szCs w:val="18" />
</w:rPr>
<w:t>This is left side block of header</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="00412C93" w:rsidRDefault="00412C93" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:jc w:val="center" />
</w:pPr>
</w:p>
<w:p w:rsidR="006D65A1" w:rsidRDefault="00412C93" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:jc w:val="center" />
</w:pPr>
<w:r>
<w:rPr>
<w:noProof />
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="266020" cy="266020" />
<wp:effectExtent l="19050" t="0" r="680" b="0" />
<wp:docPr id="1" name="Picture 0" descr="user_image.png" />
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1" />
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="0" name="user_image.png" />
<pic:cNvPicPr />
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId1" />
<a:stretch>
<a:fillRect />
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0" />
<a:ext cx="266020" cy="266020" />
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst />
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRPr="00FC69E2" w:rsidRDefault="006D65A1" w:rsidP="00FC69E2">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
<w:b />
<w:i />
<w:sz w:val="24" />
<w:szCs w:val="24" />
</w:rPr>
</w:pPr>
</w:p>
<w:p w:rsidR="00412C93" w:rsidRPr="00412C93" w:rsidRDefault="00412C93" w:rsidP="00412C93">
<w:pPr>
<w:pStyle w:val="HTMLPreformatted" />
<w:shd w:val="clear" w:color="auto" w:fill="FFFFFF" />
<w:bidi />
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:b />
<w:color w:val="212121" />
<w:sz w:val="28" />
<w:szCs w:val="28" />
<w:rtl />
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00412C93">
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:b />
<w:color w:val="212121" />
<w:sz w:val="28" />
<w:szCs w:val="28" />
<w:rtl />
</w:rPr>
<w:t>الصحيح كتلة الجانب</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00412C93" w:rsidRPr="00412C93" w:rsidRDefault="00412C93" w:rsidP="00412C93">
<w:pPr>
<w:pStyle w:val="HTMLPreformatted" />
<w:shd w:val="clear" w:color="auto" w:fill="FFFFFF" />
<w:bidi />
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:b />
<w:color w:val="212121" />
<w:sz w:val="28" />
<w:szCs w:val="28" />
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00412C93">
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:b />
<w:color w:val="212121" />
<w:sz w:val="28" />
<w:szCs w:val="28" />
<w:rtl />
</w:rPr>
<w:t>هذا هو الحق كتلة الجانب من الرأس</w:t>
</w:r>
</w:p>
<w:p w:rsidR="006D65A1" w:rsidRPr="00FC69E2" w:rsidRDefault="00412C93" w:rsidP="00412C93">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
<w:spacing w:line="276" w:lineRule="auto" />
<w:jc w:val="center" />
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
<w:b />
<w:sz w:val="24" />
<w:szCs w:val="24" />
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00FC69E2">
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial" />
<w:b />
<w:sz w:val="24" />
<w:szCs w:val="24" />
</w:rPr>
<w:t xml:space="preserve"> </w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr w:rsidR="006D65A1" w:rsidTr="00412C93">
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="3672" w:type="dxa" />
</w:tcPr>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p w:rsidR="006D65A1" w:rsidRDefault="006D65A1" w:rsidP="006D65A1">
<w:pPr>
<w:pStyle w:val="Header" />
<w:tabs>
<w:tab w:val="clear" w:pos="9360" />
</w:tabs>
</w:pPr>
</w:p>
</w:hdr>
Header1.xml
<?xml version="1.0" encoding="UTF-8"?>
<w:hdr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:p w:rsidR="00412C93" w:rsidRDefault="00412C93">
<w:pPr>
<w:pStyle w:val="Header" />
</w:pPr>
</w:p>
</w:hdr>
Header3.xml
<?xml version="1.0" encoding="UTF-8"?>
<w:hdr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:p w:rsidR="00412C93" w:rsidRDefault="00412C93">
<w:pPr>
<w:pStyle w:val="Header" />
</w:pPr>
</w:p>
</w:hdr>
[Content_Types].xml
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Override PartName="/word/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" />
<Default Extension="png" ContentType="image/png" />
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
<Default Extension="xml" ContentType="application/xml" />
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" />
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" />
<Override PartName="/word/endnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" />
<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" />
<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" />
<Override PartName="/word/footer2.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" />
<Override PartName="/word/footer3.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" />
<Override PartName="/word/footer1.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" />
<Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml" />
<Override PartName="/word/header2.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" />
<Override PartName="/word/header3.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" />
<Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" />
<Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml" />
<Override PartName="/word/header1.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" />
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
</Types>
UPDATE