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

Free Support Forum - aspose.com

Tiff to PDF Conversion

Hi,


I m testing conversion from TIFF to PDF, using this code :

try {
//Instantiate Pdf instance by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create a new section in the Pdf object
Section sec1 = pdf1.getSections().add();
//Create an image object in the section
Image image = new aspose.pdf.Image(sec1);
//Add image object into the Paragraphs collection of the section
sec1.getParagraphs().add(image);
//Set the ImageStream information
image.getImageInfo().setSystemImage(ImageIO.read(new java.net.URL(“file:////C:/path/TIFF_File.tif”)));
// set the value that all frames of tiff image need be added into PDF document
image.getImageInfo().setTiffFrame(-1);
//Save the pdf document
pdf1.save(“C:\path\TIF-ImageConversion.pdf”);
} catch(Exception e){
e.printStackTrace();
}


I attached the tif file used. Testing with aspose.pdf version 4.4.0 on jdk 1.6.

I m getting back this exception:

java.lang.RuntimeException: This picture is not supported!
at aspose.pdf.c.Abi.a(SourceFile:156)
at aspose.pdf.c.Aba.a(SourceFile:152)
at aspose.pdf.c.Aba.a(SourceFile:99)
at aspose.pdf.xml.Abi.a(SourceFile:208)
at aspose.pdf.xml.Abi.a(SourceFile:669)
at aspose.pdf.xml.Abj.a(SourceFile:578)
at aspose.pdf.xml.Acd.a(SourceFile:804)
at aspose.pdf.xml.Aar.a(SourceFile:104)
at aspose.pdf.xml.Aba.a(SourceFile:113)
at aspose.pdf.Pdf.save(SourceFile:929)
at test_project2.Test2.main(Test2.java:62)

Could you please kindly assist?

Regards

Hi Ivona,


Thanks for contacting support.

I have tested the scenario using latest release of Aspose.Pdf for Java 9.5.0 where I have used following code snippet and I am unable to notice any issue. Please try using the latest Document Object Model (DOM) of com.aspose.pdf package and in case you still face any issue, please feel free to contact.

For your reference, I have also attached the resultant PDF generated over my end.

[Java]

//
instantiate Document object
<o:p></o:p>

Document document = new Document();

// add blank page to PDF file

document.getPages().add();

// create Image object

com.aspose.pdf.Image image = new com.aspose.pdf.Image();

// set path of image file

image.setFile("c:/pdftest/TIF_File.tif");

// add image to paragraphs collection of first page of PDF document

document.getPages().get_Item(1).getParagraphs().add(image);

// save the PDF file

document.save(“c:/pdftest/TIF_File.pdf”);