Hi Tom,
please update this snippet. It was too large and now everything needed
is linked :-)
Greetings, Tobias
<?xml version="1.0"?>
<snippet language="Java" application="Office">
<keywords>
<keyword>convert</keyword>
<keyword>conversion</keyword>
<keyword>pdf</keyword>
</keywords>
<authors>
<author id="tobiaskrais" initial="true" email="[EMAIL PROTECTED]" copyright="GPL">Tobias Krais (www.design-to-use.de)</author>
</authors>
<question heading="Convert Documents">How to convert a document in an other format?
</question>
<answer>
<listing>import {%see com.sun.star.lang.XComponent};
import {%see com.sun.star.beans.PropertyValue};
import {%see com.sun.star.frame.XStorable};
import {%see com.sun.star.io.IOException};
import {%see com.sun.star.uno.UnoRuntime};
/**
* This method converts documents to other formats.
* See http://www.openoffice.org/files/documents/25/3042/filter_list_ooo_2_0.html
*
* @param targetFilename Name of the file, which is the target of the export.
* @param conversionFilter Contains the conversion filter (see link above).
*/
public void convert(String targetFilename, String conversionFilter)
{
// How to get the XComponent, see {%internal ../Office/Office.OpenDocumentFromURL.snip}
XStorable xStorable = (XStorable)
UnoRuntime.queryInterface(XStorable.class, this.xComponent);
// Set properties for conversions
PropertyValue[] conversionProperties = new PropertyValue[2];
conversionProperties[0] = new PropertyValue();
conversionProperties[0].Name = "Overwrite";
conversionProperties[0].Value = new Boolean(true);
conversionProperties[1] = new PropertyValue();
conversionProperties[1].Name = "FilterName";
conversionProperties[1].Value = conversionFilter;
// Convert
try {
// See {%internal ../Office/Office.CreateUNOCompatibleURL.snip} for method createUNOFileURL(targetFilename);
xStorable.storeToURL(createUNOFileURL(targetFilename),
conversionProperties);
} catch (IOException e) {
e.printStackTrace();
}
}</listing>
</answer>
<versions>
<version number="2.0.x" status="tested"/>
<version number="1.1.x" status="untested"/>
</versions>
<operating-systems>
<operating-system name="All"/>
</operating-systems>
<changelog>
<change author-id="tobiaskrais" date="2006-12-11">Linked other methods from the snippet base and thus simplified the method</change>
</changelog>
</snippet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]