Hi,
I have been evaluating GroupDocs conversion with converting some of the basic Open Office format documents to PDF.
When I try to convert .odt or .ods files to PDF I get below exception. I tried with creating very basic odt and ods documents. However all MS Office formats work correctly.
This happens with the version 17.3.0.
These are essential document formats that I want to support in my upcoming projects.
Exception in thread “main” class com.groupdocs.conversion.internal.c.a.s.kt: Not a Open Office presentation
com.groupdocs.conversion.internal.c.a.s.uh.a(Unknown Source)
com.groupdocs.conversion.internal.c.a.s.kB.(Unknown Source)
com.groupdocs.conversion.internal.c.a.s.kA.h(Unknown Source)
com.groupdocs.conversion.internal.c.a.s.kA.H(Unknown Source)
com.groupdocs.foundation.a.b.c(Unknown Source)
com.groupdocs.foundation.a.b.a(Unknown Source)
com.groupdocs.foundation.a.b.e(Unknown Source)
com.groupdocs.conversion.domain.b.q(Unknown Source)
com.groupdocs.conversion.domain.b.a(Unknown Source)
com.groupdocs.conversion.handler.ConversionHandler.b(Unknown Source)
com.groupdocs.conversion.handler.ConversionHandler.b(Unknown Source)
com.groupdocs.conversion.handler.ConversionHandler.convert(Unknown Source)
com.Processor.convertToHtmlAsStream(Processor.java:46)
com.Main.main(Main.java:16)
at com.groupdocs.conversion.internal.c.a.s.uh.a(Unknown Source)
at com.groupdocs.conversion.internal.c.a.s.kB.(Unknown Source)
at com.groupdocs.conversion.internal.c.a.s.kA.h(Unknown Source)
at com.groupdocs.conversion.internal.c.a.s.kA.H(Unknown Source)
at com.groupdocs.foundation.a.b.c(Unknown Source)
at com.groupdocs.foundation.a.b.a(Unknown Source)
at com.groupdocs.foundation.a.b.e(Unknown Source)
at com.groupdocs.conversion.domain.b.q(Unknown Source)
at com.groupdocs.conversion.domain.b.a(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.b(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.b(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.convert(Unknown Source)
at com.Processor.convertToHtmlAsStream(Processor.java:46)
at com.Main.main(Main.java:16)
Thanks for your inquiry. We are not able to reproduce this issue at our end. Please find the sample OpenOffice documents and output files. OpenOffice to PDF.zip (46.5 KB)
In order to further investigate your issue, we need the problematic files. Can you please share the ODT and ODS files you are trying to convert?
Thanks for replying back.
I tried both of the files (odt & ods) in your zip and got the same exception that I got above.
I am creating a FileInputStream and passing it to the ‘convert’ method as belows.
Please let me know if I am doing the conversions incorrectly.
public void convertToPdf(FileInputStream fis) throws Exception {
PdfSaveOptions saveOption = new PdfSaveOptions();
saveOption.setConvertFileType(PdfSaveOptions.PdfFileType.PDF);
saveOption.setOutputType(OutputType.String);
ConversionHandler conversionHandler = new ConversionHandler(Utilities.getConfiguration());
String path = conversionHandler.<String>convert(fis, saveOption);
System.out.println(path);
}
Thanks for sharing the details. We reproduced this issue at our end. However, with few amendments in the code we can resolve it. Please utilize the code given below in your method (convertToPDF) and share your experience.
@atirtahir3
Thanks for the reply.
The solution you provided worked for me.
The only essential thing I figured here is convert method explicitly needs the name of the file. Looks like it identifies the type of file in the input stream.
Let me know, if I am wrong.
Using file extension for filetype is not reliable as not everyone honors filetype naming. The method that we used with 16.10.1 was to read all files as input streams then using ConversionHandler.getSaveOptions(inputStream). We’re getting a number of the same errors related to Open Office slides. This seems like a regression or deprecation without notice. What is the plan to correct this?
We’ve logged this issue in our internal issue tracking system with ID:CONVERSIONJAVA-442. As we get any update from the concerned team, we’ll apprise you.
Great, thank you. One thing that I’ve noticed with this error is that it’s often being thrown for files that are Libre/Open Office Writer(odt) docs. We’re not using filename conversion calls, rather we are using streams. Hope this info helps.
Thanks for the further details. We’ve shared your scenario with concerned team and they are investigating the issue. As we get any update from them, we’ll notify you.