We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Tiff to pdf conversion error


tried to convert tiff to pdf using aspose code below

Pdf pdf1 = new Pdf();

//Create a section in the Pdf object

Section sec1 = pdf1.getSections().add();

//Create an image object in the section

aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);

//Add image object into the Paragraphs collection of the section


//Set the path of image file


//Set the path of image file

// img1.getImageInfo().setTitle("JPEG image");

//Save the Pdf


Getting below error can anyone help in this

Exception in thread "main" java.lang.IllegalArgumentException: Unable to read file. Exception: Unsupported compression type Ojpeg

at com.aspose.pdf.internal.p338.z2.m1(Unknown Source)

at com.aspose.pdf.internal.p338.z2.m1(Unknown Source)

at com.aspose.pdf.internal.p338.z2.m2(Unknown Source)

at com.aspose.pdf.internal.p345.z1.m2(Unknown Source)

at com.aspose.pdf.internal.p345.z1.getNumImages(Unknown Source)

at com.aspose.pdf.internal.p273.z1.m2(Unknown Source)

at com.aspose.pdf.internal.p273.z1.m1(Unknown Source)

at com.aspose.pdf.internal.p273.z1.m6(Unknown Source)

at com.aspose.pdf.internal.p237.z2.m1(Unknown Source)

at com.aspose.pdf.internal.p237.z2.(Unknown Source)

at com.aspose.pdf.internal.p237.z2.(Unknown Source)

at aspose.pdf.internal.z146.m1(Unknown Source)

at aspose.pdf.internal.z148.m1(Unknown Source)

at aspose.pdf.internal.z284.m1(Unknown Source)

at aspose.pdf.internal.z284.m1(Unknown Source)

at aspose.pdf.internal.z285.m1(Unknown Source)

at aspose.pdf.internal.z303.m1(Unknown Source)

at aspose.pdf.xml.DocumentBase.m1(Unknown Source)

at aspose.pdf.internal.z277.m1(Unknown Source)

at aspose.pdf.Pdf.save(Unknown Source)

at aspose.Test.main(Test.java:55)

Caused by: com.aspose.pdf.internal.p230.z88: Unsupported compression type Ojpeg

... 21 more

Hi Ganesh,

Thanks for your inquiry. Please use new DOM approach to convert Image to PDF as suggested below. Hopefully it will resolve the issue. If issue persist then please share your source TIFF image, we will test the scenario at our end and will guide you accordingly.

String outFile = myDir + “ImageToPDF.pdf”;<o:p></o:p>

String inFile = myDir + “Test.tif”;<o:p></o:p>

Document doc = new Document();<o:p></o:p>

Page page = doc.getPages().add();<o:p></o:p>

java.io.FileInputStream imageStream = new java.io.FileInputStream(new java.io.File(inFile));<o:p></o:p>

//Create an image object<o:p></o:p>

com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();<o:p></o:p>

//Add the image into paragraphs collection of the section<o:p></o:p>


//Set the ImageStream to a MemoryStream object<o:p></o:p>


//Set margins so image will fit, etc.<o:p></o:p>






<o:p> </o:p>

<o:p>Please feel free to contact us for any further assistance.</o:p>


<o:p>Best Regards,</o:p>