使用 cli dll 尝试使用以下代码
public conversion()
{
unoidl.com.sun.star.uno.XComponentContext localContext =uno.util.Bootstrap.bootstrap();
unoidl.com.sun.star.lang.XMultiServiceFactory multiServiceFactory =(unoidl.com.sun.star.lang.XMultiServiceFactory)localContext.getServiceManager();
XComponentLoader componentLoader =(XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
XComponent xComponent = componentLoader.loadComponentFromURL(PathConverter(FileName1),"_blank", 0,new PropertyValue[] {MakePropertyValue("Hidden", true)});
unoidl.com.sun.star.beans.PropertyValue [] propertyValues;
propertyValues = new unoidl.com.sun.star.beans.PropertyValue[2];
// Setting the flag for overwriting
propertyValues[0] = new unoidl.com.sun.star.beans.PropertyValue();
propertyValues[0].Name = "Overwrite";
propertyValues[0].Value = new Any(true);
// Setting the filter name
propertyValues[1] = MakePropertyValue("FilterName", "HTML (StarWriter)");
/*propertyValues[1] = new unoidl.com.sun.star.beans.PropertyValue();
propertyValues[1].Name = "FilterName";
propertyValues[1].Value = new uno.Any("HTML (StarWriter)"); // writer_pdf_Export , swriter: MS Word 97 , HTML (StarWriter) ,*/
XStorable xStorable = xComponent as XStorable;xStorable.storeToURL(PathConverter(FileName),propertyValues);
}
有关要导出的过滤器名称的完整列表,请查看我之前给出的另一个答案。