 | OO-Snippets: Convert DocumentsCommons| Keywords | convert, conversion, pdf |
|---|
| Language | Java |
|---|
| Application | Office |
|---|
| Authors | Tobias Krais (www.design-to-use.de) (initial)
|
|---|
| Supported Versions | 2.0.x 1.1.x |
|---|
| Supported OS | All |
|---|
| Question | How to convert a document in an other format?
|
|---|
| Answer | |
|---|
import com.sun.star.lang.XComponent;
import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XStorable;
import com.sun.star.io.IOException;
import com.sun.star.uno.UnoRuntime;
This method converts documents to other formats.
@param targetFilename
@param conversionFilter
public void convert(String targetFilename, String conversionFilter)
{
XStorable xStorable = (XStorable)
UnoRuntime.queryInterface(XStorable.class, this.xComponent);
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;
try {
xStorable.storeToURL(createUNOFileURL(targetFilename),
conversionProperties);
} catch (IOException e) {
e.printStackTrace();
}
}
|
Changelog| Date | User | Modification |
|---|
| 2006-12-11 | tobiaskrais | Linked other methods from the snippet base and thus simplified the method |
|