corigo2
|
Posted: November 07, 2008 04:49 by corigo2
|
| Any pointers on how to use the API to generate alternate document types including PDF, MS Word, and Excel? |
Save As - Generating alternate file formats
32 topics, 70 posts
» Share this
Replies: 3 - Last Post: March 06, 2009 19:36
by: snowch
by: snowch
showing 1 - 4 of 4
minskybelieve
|
Posted: November 07, 2008 06:40 by minskybelieve
|
|
I assumed you are using Java ... One of the approaches I found is to add the "FilterName" property with value "writer_pdf_Export" in XStorable. Wonder if anyone actually compile a list or know a URL where they list all the properties of the various Classes like XStorable. It would come in very handy ... Best regards minskybelieve |
Michael Brauer
|
Posted: November 07, 2008 09:54 by Michael Brauer
|
|
Right now, neither ODFDOM nor AODL support other file formats than ODF. The XStoragble solution won't work with these frameworks. XStoragable is an interface of the OpenOffice.org API. The projects hosted on odftoolkit.org are not related to OpenOffice.org, and do not support OpenOffice.org's API. |
snowch
|
Posted: March 06, 2009 19:36 by snowch
|
|
jodconverter works for me (using spring): <bean name="connection" class="com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection"> <constructor-arg value="8100"/> </bean> <bean name="converter" class="com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter"> <constructor-arg ref="connection"/> </bean> <bean name="converterUtil" class="net.christophersnow.outputs.openoffice.ConverterUtil"> <constructor-arg ref="converter"/> <constructor-arg ref="connection"/> </bean> package net.christophersnow.outputs.openoffice; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.net.ConnectException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.artofsolving.jodconverter.DefaultDocumentFormatRegistry; import com.artofsolving.jodconverter.DocumentConverter; import com.artofsolving.jodconverter.DocumentFormat; import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; public class ConverterUtil { private DocumentConverter converter; private OpenOfficeConnection connection; public ConverterUtil(DocumentConverter converter, OpenOfficeConnection connection) { this.converter = converter; this.connection = connection; } public void convert(File inputFile, File outputFile) throws ConnectException { connection.connect(); converter.convert(inputFile, outputFile); connection.disconnect(); } public void odt2pdfConvert( InputStream inputStream, OutputStream outputStream ) throws ConnectException { DefaultDocumentFormatRegistry registry = new DefaultDocumentFormatRegistry(); DocumentFormat inFormat = registry.getFormatByFileExtension("odt"); DocumentFormat outFormat = registry.getFormatByFileExtension("pdf"); convert(inputStream, inFormat, outputStream, outFormat); } public void convert( InputStream inputStream, DocumentFormat inFormat, OutputStream outputStream, DocumentFormat outFormat) throws ConnectException { connection.connect(); converter.convert(inputStream, inFormat, outputStream, outFormat); connection.disconnect(); } public static void main( String[] args ) throws ConnectException, FileNotFoundException { ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); ConverterUtil util = (ConverterUtil) context.getBean("util", ConverterUtil.class); File inputFile = new File("/home/snowch/Desktop/mydoc.odt"); File outputFile = new File("/home/snowch/Desktop/mydoc-jod.pdf"); InputStream is = new FileInputStream(inputFile); OutputStream os = new FileOutputStream(outputFile); DefaultDocumentFormatRegistry registry = new DefaultDocumentFormatRegistry(); DocumentFormat inFormat = registry.getFormatByFileExtension("odt"); DocumentFormat outFormat = registry.getFormatByFileExtension("pdf"); util.convert(is, inFormat, os, outFormat); } } |
Replies: 3 - Last Post: March 06, 2009 19:36
by: snowch
by: snowch


