To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=108268
User annmcdonald changed the following:
What |Old value |New value
================================================================================
Summary|Images that are part of ht|Images that are part of ht
|ml files shrink in convert|ml files shrink when conve
|ed pdf through soffice.exe|rted to pdf through soffic
| |e.exe
--------------------------------------------------------------------------------
------- Additional comments from [email protected] Tue Jan 12 15:28:31
+0000 2010 -------
/**
* Convert a given file to a pdf using specific openoffice installation
* @param fileName Then full path of the file for pdf conversion
* @param unoUrl The openoffice connection url
* @return Fullpath to the converted pdf
*/
public String convert2PDF(String fileName, String unoUrl) {
String targetURL =null;
XDesktop XDesktop = null;
String convertedPDF=null;
XComponent xComponent = null;
XStorable xstore=null;
XComponentContext xContext=null;
if(new java.io.File(fileName).exists()){
try {
String sourceURL = "file:///" + fileName.replace
('\\', '/');
targetURL = sourceURL + ".pdf".trim();
log_msg("Targetting pdf to "+ targetURL);
// Get Basic context
xContext =
com.sun.star.comp.helper.Bootstrap.createInitialComponentContext( null );
// Get the service manager
XMultiComponentFactory xMCF =
xContext.getServiceManager();
// Creates UnoUrlResolver component
Object obj = xMCF.createInstanceWithContext
("com.sun.star.bridge.UnoUrlResolver", xContext );
XUnoUrlResolver xurlresolver = (XUnoUrlResolver)
UnoRuntime.queryInterface(XUnoUrlResolver.class, obj );
log_msg("..starting ooffice");
startService(this.ooSilentStart);
// Connect to the soffice.exe
obj = xurlresolver.resolve(unoUrl );
log_msg("uno url received = " + unoUrl);
// Create a service manager from the initial
object
xMCF = (XMultiComponentFactory)
UnoRuntime.queryInterface( XMultiComponentFactory.class, obj );
// Query for the XPropertySet interface.
XPropertySet xpropertysetMultiComponentFactory
= (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xMCF );
// Get the default context from the office
server.
obj =
xpropertysetMultiComponentFactory.getPropertyValue( "DefaultContext" );
xContext = (XComponentContext)
UnoRuntime.queryInterface(XComponentContext.class, obj );
XComponentLoader loader=null;
Object oDesktop = xMCF.createInstanceWithContext
("com.sun.star.frame.Desktop", xContext);
loader = (
XComponentLoader ) UnoRuntime.queryInterface( XComponentLoader.class,oDesktop);
XDesktop = (XDesktop)UnoRuntime.queryInterface
(XDesktop.class, oDesktop);
log_msg("Got OO Connection");
// Load the source document & prepare for
storing
PropertyValue[] sArgs = new PropertyValue[1];
sArgs[0] = new PropertyValue();
sArgs[0].Name = "Hidden";
sArgs[0].Value = Boolean.FALSE;
XComponent docObj = loader.loadComponentFromURL
(sourceURL, "_blank", 0, sArgs );
log_msg("url loaded");
xstore = (XStorable) UnoRuntime.queryInterface(
XStorable.class, docObj );
// Target file properties
PropertyValue tArgs[] = new PropertyValue[4];
tArgs[0] = new PropertyValue();
tArgs[0].Name = "FilterName";
//tArgs[0].Value = new String
("writer_web_pdf_Export");
tArgs[0].Value = new String
("writer_pdf_Export");
tArgs[1] = new PropertyValue();
tArgs[1].Name = "Overwrite";
tArgs[1].Value = new Boolean(true);
tArgs[2] = new PropertyValue();
tArgs[2].Name = "CompressionMode";
tArgs[2].Value = "8";
tArgs[3] = new PropertyValue();
tArgs[3].Name = "Size";
tArgs[3].Value = "LEGAL";
// Storing and converting the document
log_msg("Begin Conversion");
xstore.storeToURL( targetURL, tArgs );
xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class, xstore );
log_msg("...Conversion done");
convertedPDF=fileName +".pdf";
bSuccess=true;
}catch(com.sun.star.task.ErrorCodeIOException ec){
log_exceptions
("XL_RESTART_OF_OPENOFFICE_REQUIRED_OO_SERVICE_WAS BLOCKED,
sOffice.exe/soffice.bin. Run OpenOfficeStartup.cmd, & delete the
application '.LCK' file ", ec);
// String dir = System.getProperty("user.dir")
+ "/PDFConvertRunning.LCK";
// java.io.File f = new java.io.File(dir);
// f.delete();
System.exit(1);
}catch(java.io.IOException ei ) {
xContext = null;
log_exceptions("XL_ERROR_IO_EXCEPTION", ei);
}catch(NullPointerException en){
log_exceptions("XL_PDF_CONVERSION_FAILURE,
CHECK file exists " + fileName, en);
}catch(com.sun.star.lang.IllegalArgumentException eA){
log_exceptions("XL_PDF_CONVERSION_FAILURE, FILE
MAY BE CORRUPT, try opening it manually on " + fileName, eA);
}catch(Exception ex ){
log_exceptions("XL_PDF_CONVERSION_FAILURE " +
fileName, ex);
}finally {
XCloseable closeable = (XCloseable)
UnoRuntime.queryInterface(XCloseable.class, xstore);
if (closeable != null) {
try {
closeable.close(true);
} catch (CloseVetoException closeVetoException) {
log_exceptions
("XL_ERROR_COULD_NOT_CLOSE_OO_CONNECTION", new Exception(" XCloseable vetoed"));
}
} else {
try{
xComponent.dispose();
}catch(com.sun.star.lang.DisposedException de ){
log_exceptions
("XL_ERROR_COULD_NOT_DISPOSE_OF_OO_CONNECTION", de);
}
}
XDesktop=null;
xComponent = null;
xstore=null;
xContext=null;
}
}
return convertedPDF;
}
}
---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]