caoticud Newbie

Joined: 21 Feb 2012 Posts: 2 Location: Kolkata, India
|
Posted: Wed Jun 20, 2012 4:08 am Post subject: Exporting ODP slides in JPG or PNG format |
|
|
Our aim is simple - to export all slides of a presentation file as JPG images.
Constraints are
Platform - CentOS 5.8, 32 bit
Office suite - LibreOffice 3.4.*
Batch process, web environment, Java 1.5, tomcat 6.0.35
Solution must be in Java
We tried in following ways
Method 1 - Converted ODP in PDF and created images from PDF, this works fine - no issue.
Method 2 - Tried to export slides as JPG with com.sun.star.drawing.GraphicExportFilter. - Works fine in standalone mode, fails in web container. Exception - com.sun.star.lang.DisposedException, detailed stack-trace later
Method 3 - Tried to get the XController object and use storeToURL method to save the current slide as image. Again, works fine in standalone mode, fails in web container. Exception - com.sun.star.lang.DisposedException
Reason for this exception is stated as multi-threaded access of java-libreoffice bridge. But we have made sure there is only one process, one bridge and strictly single threaded execution of the job.
Exception :
com.sun.star.lang.DisposedException: java.io.IOException: com.sun.star.io.IOException: EOF reached - socket,host=127.0.0.1,port=9999,tcpNoDelay=1,localHost=localhost.localdomain,localPort=57499,peerHost=localhost.localdomain,peerPort=9999
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge$MessageDispatcher.run(java_remote_bridge.java:158)
Method 2
| Code: |
Object graphicExportFilter = officeConnectorManager.getService("com.sun.star.drawing.GraphicExportFilter");
XExporter graphicExporter = OfficeUtil.getQueryInterface(XExporter.class, graphicExportFilter);
XFilter graphicFilter = OfficeUtil.getQueryInterface(XFilter.class, graphicExportFilter);
...........
get draw pages
...........
for (...) {
PropertyValue[] propertyValues = new PropertyValue[4];
propertyValues[0] = new PropertyValue();
propertyValues[1] = new PropertyValue();
propertyValues[2] = new PropertyValue();
propertyValues[3] = new PropertyValue();
propertyValues[0].Name = "MediaType";
propertyValues[0].Value = "image/jpeg";
propertyValues[1].Name = "FilterData";
propertyValues[1].Value = presentationFilterData; // appropriate filter data
propertyValues[2].Name = "URL";
propertyValues[2].Value = OfficeUtil.toUrl(outFile);
propertyValues[3].Name = "Hidden";
propertyValues[3].Value = true;
xDrawPageObject = allSlides.getByIndex(i);
currentSlide = OfficeUtil.getQueryInterface(XDrawPage.class, xDrawPageObject);
graphicExporter.setSourceDocument(OfficeUtil.getQueryInterface(XComponent.class , currentSlide));
currentThumbImage = ThumbHandlerUtil.getOutputFile(fileInfo.getOutDirPath(), (i + 1));
graphicFilter.filter(propertyValues);
}
|
Method 3
| Code: |
XStorable storableDoc = OfficeUtil.getQueryInterface(XStorable.class, componentPresentation);
XModel docModel = OfficeUtil.getQueryInterface(XModel.class, componentPresentation);
XController docController = docModel.getCurrentController();
XDrawView drawView = OfficeUtil.getQueryInterface(XDrawView.class, docController);
...........
get draw pages
...........
for (...) {
PropertyValue[] propertyValues = new PropertyValue[3];
propertyValues[0] = new PropertyValue();
propertyValues[1] = new PropertyValue();
propertyValues[2] = new PropertyValue();
propertyValues[0].Name = "FilterName";
propertyValues[0].Value = OfficeFilterRegistry.getFilter(fileType, "jpg");
propertyValues[1].Name = "Overwrite";
propertyValues[1].Value = true;
propertyValues[2].Name = "FilterData";
propertyValues[2].Value = getPresentationFilterData(width, height); // appropriate filter data
currentThumbImage = ThumbHandlerUtil.getOutputFile(fileInfo.getOutDirPath(), (i + 1));
xDrawPageObject = allSlides.getByIndex(i);
currentSlide = OfficeUtil.getQueryInterface(XDrawPage.class, xDrawPageObject);
drawView.setCurrentPage(currentSlide);
storableDoc.storeToURL(OfficeUtil.toUrl(currentThumbImage),
propertyValues );
}
|
It will be great if you can help me solve this issue - this will affect greatly on our app performance, output quality and stability. _________________ Regards
Udita |
|