Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 238 by
Mr.M.McM...@googlemail.com: PDF Images lost at xdocreport
1.0.0 in felix osgi container
http://code.google.com/p/xdocreport/issues/detail?id=238
What steps will reproduce the problem?
Docx to PDF conversion of images loses image.
What is the expected output? What do you see instead?
The PDF contains no image: the image should be in the PDF.
What version of the product are you using? On what operating system?
xdocreport 1.0.0 in felix OSGi on Windows 7: some jars are re-wrapped.
Please provide any additional information below.
When generating from docx to pdf, images are not being written to the
generated pdf, but only when I am running in a felix osgi container.
Running outside of this enviroment generates images successfully when using
the same jars. So there appears to be a config issue with the bundle
wrappers. Some of the bundles I am using are wrapped by you, some by me.
I was previously running xdocreport 0.9.8 as and wrapped several bundles in
order to get up and running in osgi, as per:
http://code.google.com/p/xdocreport/issues/detail?id=159. Images were being
successfully generated.
Migrating to xdocreport 1.0.0 involved:
. modifying:
- my existing poi wrapper which wraps:
org.apache.poi:poi:3.8
org.apache.poi:poi-ooxml:3.8
org.apache.poi:ooxml-schemas:1.1
in order to export
org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.
. wrapping (to modify imports/exports to coexist with my config):
- fr.opensagres.xdocreport.converter-1.0.0.jar
- fr.opensagres.xdocreport.converter.docx.xwpf-1.0.0.jar (I also wrapped
this at 0.9.8)
. using unmodified:
- fr.opensagres.xdocreport.core-1.0.0.jar
- fr.opensagres.xdocreport.document-1.0.0.jar
- fr.opensagres.xdocreport.document.docx-1.0.0.jar
- fr.opensagres.xdocreport.itext.extension-1.0.0.jar
- fr.opensagres.xdocreport.template-1.0.0.jar
- fr.opensagres.xdocreport.template.freemarker-1.0.0.jar
- org.apache.poi.xwpf.converter.core-1.0.0.jar
- org.apache.poi.xwpf.converter.pdf-1.0.0.jar
- org.apache.poi.xwpf.converter.xhtml-1.0.0.jar
The problem is related to xmlbeans representing the image as XmlAnyTypeImpl
object when it should be a CTPicture.
The line it fails on is
org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitGraphicalObject(..)
line 1223 (org.apache.poi.xwpf.converer.core-1.0.0.jar). The object is an
XmlAnyTypeImpl object rather than a CTPicture object so it skips some
significant code. I cannot debug the getObject() call.
XmlObject o = c.getObject();
if ( o instanceof CTPicture ) { // test fails as o is XmlAnyType
CTPicture picture = (CTPicture) o;
// extract the picture if needed
IImageExtractor extractor = getImageExtractor();
Note that prior to this in
org.apache.poi.xwpf.usermodel.XWPFRun.getCTPictures(...) line 150 it caters
for an XmlAnyTypeImpl object and creates a CTPicture from it.
if(pict instanceof XmlAnyTypeImpl) {
// Pesky XmlBeans bug - see Bugzilla #49934
try {
pict = CTPicture.Factory.parse(pict.toString());
} catch(XmlException e) {
throw new POIXMLException(e);
}
}
Applying the same check and fix in
XWPFDocumentVisitor.visitGraphicalObject(..) resolves my problem. However,
given that this only occurs in the osgi environment (I get a CTPicture
"org.openxmlformats.schemas.drawingml.x2006.picture.impl.CTPictureImpl" at
both points when running outside osgi) I believe this is not the correct
fix - there must be some additional config required. There is nothing in
the log files which supplies any clues regarding what to do.
I noticed that the pom for your
org.apache.poi.xwpf.converter.core-1.0.0.jar contains an exclusion which
hints at some problems in this area:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8</version>
<exclusions>
<!-- surprisingly this artifect contains a subset of
org.apache.poi:ooxml-schemas:1.1 -->
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
And there is also the issue referenced in the commment in the XWPFRun code
which again hints at similar problems:
https://issues.apache.org/bugzilla/show_bug.cgi?id=49934.
I have tinkered with the import/exports in the bundles that I have wrapped
to try expose the packages which contain the CTPictures related class files
but without success. I'm basically working by guesswork.
Can you provide any suggestions regarding what is occurring here and how to
resolve it?
--
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