Open GoogleCodeExporter opened 8 years ago
Hi,
At first, why you have wrapping XDocReport bundles :
- 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)
If there are a problem with thoses JARs in OSGi context, it should be fixed.
@Pascal: could you see this issue please?
Many thank's
Original comment by angelo.z...@gmail.com
on 21 Mar 2013 at 9:28
At 0.9.8 I followed the advice at
http://code.google.com/p/xdocreport/issues/detail?id=159 to run in OSGi.
Specifically the wrapper is needed, as reported in 159, to avoid:
java.lang.NoClassDefFoundError: fr/opensagres/xdocreport/core/utils/StringUtils
At 1.0.0 for similar reasons I again wrapped the jar, ie in order to import
fr.opensagres.xdocreport.core.utils which is missing from your version of the
wrapper.
Note that this is only required when executing the conversion via:
IXDocReport report = ...
report.convert(context, Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF), os);
but it is not required when executing the conversion via:
XWPFDocument document = ...
PdfConverter.getInstance().convert(document, os, PdfOptions.create())
The other wrapper was modified in error by me. In accounting for the addition
of the import of org.apache.poi.xwpf.converter.core to
fr.opensagres.xdocreport.converter.docx.xwpf-1.0.0, I wrapped
fr.opensagres.xdocreport.converter-1.0.0 and imported it there. So there was no
need to wrap fr.opensagres.xdocreport.converter-1.0.0.
I have now rectified this situation so that I only now wrap
fr.opensagres.xdocreport.converter.docx.xwpf-1.0.0.jar to reolve the
StringUtils problem. However, the same lost image issue occurs when converting
a docx to a PDF: ie XmlAnyTypeImpl object rather than a CTPicture object so
image is lost.
I also followed the wrapping advice from
http://code.google.com/p/xdocreport/issues/detail?id=159 for POI (using the
that issue's attached pom.xml). When reusing this with your
org.apache.poi.xwpf.converter.core 1.0.0 there was a problem starting that
bundle:
org.osgi.framework.BundleException: Unresolved constraint in bundle org.apache.poi.xwpf.converter.core [89]: package;
(package=org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing)
hence, my exposing
org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing in my POI
wrapper.
My suspicion is that more of these org.openxmlformats.schemas are required. I
tried exporting the CTPictures related ones but it made no difference. Should
the org.apache.poi.xwpf.converter.core wrapper perhaps import some of these
other schema packages?
Can you provide any suggestions regarding what is occurring here and how to
resolve it?
Original comment by Mr.M.McM...@googlemail.com
on 21 Mar 2013 at 4:18
Hi there.
Do you have any thoughts about what is happening here or how to resolve this
issue?
Thanks.
Original comment by Mr.M.McM...@googlemail.com
on 28 Mar 2013 at 9:01
Hi,
on the dev branch i add the missing package on the converter fragments
(fr.opensagres.xdocreport.core.utils).
If you want to test, our jars are deployed to
https://oss.sonatype.org/content/repositories/snapshots/.
Not sure I get your point with POI packages but I suspect Bnd may miss
Import-package on POI.
I suggest to add
DynamicImport-Package: org.apache.poi.* on xdocreport XMPF converter.
what do u think ?
Original comment by pascal.leclercq
on 30 Mar 2013 at 10:39
I tried the DynamicImport-Package as suggested but the image was still lost.
Do you understand the behaviour? Is the image objcet created as an XmlAnyType
rather than a CTPicture because some package is incorrectly exported in the POI
wrapper (from http://code.google.com/p/xdocreport/issues/detail?id=159) or
because it is incorrectly imported by xdocreport 1.0.0? Why did it work with
xdocreport 0.9.8?
Original comment by Mr.M.McM...@googlemail.com
on 3 Apr 2013 at 9:13
I have doen a big refactoring in XDocReport 1.0.0 for docx->pdf converter for
images to improve it (manage aboslute image, etc)
In 0.9.8, pictures are visited like this :
---------------------------------------------------------------------
protected void visitPictures( XWPFRun run, T parentContainer )
throws Exception
{
List<XWPFPicture> embeddedPictures = run.getEmbeddedPictures();
for ( XWPFPicture picture : embeddedPictures )
{
visitPicture( picture, parentContainer );
}
}
---------------------------------------------------------------------
See
https://code.google.com/p/xdocreport/source/browse/thirdparties-extension/org.ap
ache.poi.xwpf.converter/src/main/java/org/apache/poi/xwpf/converter/internal/XWP
FElementVisitor.java?name=xdocreport-0.9.8
In 1.0.0, it is visited like this :
------------------------------------------------------------------
private void visitGraphicalObject( T parentContainer, CTGraphicalObject
graphic, Float offsetX,
STRelFromH.Enum relativeFromH, Float offsetY, STRelFromV.Enum relativeFromV )
throws Exception
{
if ( graphic != null )
{
CTGraphicalObjectData graphicData = graphic.getGraphicData();
if ( graphicData != null )
{
XmlCursor c = graphicData.newCursor();
c.selectPath( "./*" );
while ( c.toNextSelection() )
{
XmlObject o = c.getObject();
if ( o instanceof CTPicture )
{
CTPicture picture = (CTPicture) o;
// extract the picture if needed
IImageExtractor extractor = getImageExtractor();
if ( extractor != null )
{
XWPFPictureData pictureData = getPictureData( picture );
if ( pictureData != null )
{
try
{
extractor.extract( WORD_MEDIA + pictureData.getFileName(), pictureData.getData() );
}
catch ( Throwable e )
{
LOGGER.log( Level.SEVERE,
"Error while extracting the image " + pictureData.getFileName(), e );
}
}
}
// visit the picture.
visitPicture( picture, offsetX, relativeFromH, offsetY, relativeFromV, parentContainer );
}
}
c.dispose();
}
}
}
-----------------------------------------
See
https://code.google.com/p/xdocreport/source/browse/thirdparties-extension/org.ap
ache.poi.xwpf.converter.core/src/main/java/org/apache/poi/xwpf/converter/core/XW
PFDocumentVisitor.java?name=xdocreport-1.0.0
If I remember I do that to keep the oroder of image, text, image text etc.
Perhaps we should apply your patch :
-------------------------------------
if(pict instanceof XmlAnyTypeImpl) {
// Pesky XmlBeans bug - see Bugzilla #49934
try {
pict = CTPicture.Factory.parse(pict.toString());
} catch(XmlException e) {
throw new POIXMLException(e);
}
}
-------------------------------------
I don't know?
Original comment by angelo.z...@gmail.com
on 3 Apr 2013 at 9:51
I'm trying to convert docx to pdf, I'm not seeing the images in header section
converted in pdf. Can you please help? I'm using xdocreport 1.0.0 version
Original comment by gha...@gmail.com
on 23 May 2013 at 3:35
At first last version is 1.0.2. Please test your docx with this version.
Are you in OSGi env? If no, your problem is not linked to this issue, so please
create a new issue if 1.0.2 doesn't resolve your problem by attaching your docx.
Original comment by angelo.z...@gmail.com
on 23 May 2013 at 7:48
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 com.medikm.util.PdfConversion.convertDocToPDF(PdfConversion.java:131)
at com.medikm.util.PdfConversion.convertFileToPDF(PdfConversion.java:405)
at com.medikm.servlet.ResourceUploadServlet.doPost(ResourceUploadServlet.java:134)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.medikm.filter.UserAuthFilter.doFilter(UserAuthFilter.java:43)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.medikm.filter.DispatcheFilter.doFilter(DispatcheFilter.java:133)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.NullPointerException
at org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.getWidth(XWPFTableUtil.java:273)
at org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:284)
at org.apache.poi.xwpf.converter.core.utils.XWPFTableUtil.computeColWidths(XWPFTableUtil.java:127)
at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitTable(XWPFDocumentVisitor.java:828)
at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.visitBodyElements(XWPFDocumentVisitor.java:246)
at org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor.start(XWPFDocumentVisitor.java:194)
at org.apache.poi.xwpf.converter.pdf.PdfConverter.doConvert(PdfConverter.java:55)
... 29 more
how to solve this problem
Original comment by rohit.mc...@gmail.com
on 24 Feb 2014 at 12:00
Original issue reported on code.google.com by
Mr.M.McM...@googlemail.com
on 21 Mar 2013 at 9:10