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

Free Support Forum - aspose.com

DPI is not properly update to pdf output while converting tiff file as input

While trying to convert a sample tiff to pdf/a-2 the DPI does not set properly to the resulting PDF with the same value.


Can you please share that which API you are using along with used sample code, source file and generated output with us.

Hi mudassir.fayyaz

i am using aspose.pdf and aspose.imaging .

Code snippet:

public void Imagetif2() throws Exception {
java.io.FileInputStream fs;
com.aspose.imaging.Image image = com.aspose.imaging.Image.load(“file_example_TIFF_10MB.tiff”);
try {
System.out.println(" Image details before conversion ");
System.out.println(“image width:” +image.getWidth());
System.out.println(“image height:” + image.getHeight());
System.out.println(“image horizontal resolution:” + ((RasterImage) image).getHorizontalResolution());
System.out.println(“image vertical resolution:” + ((RasterImage) image).getVerticalResolution());
PdfOptions pdfOptions = new PdfOptions();
double width=image.getWidth()(72/((RasterImage)image).getHorizontalResolution());
double height=image.getHeight()
pdfOptions.setPageSize(new SizeF((int)width, (int)height));
image.save(“file_example_TIFF_10MB.pdf”, pdfOptions);

			com.aspose.pdf.Document document = new com.aspose.pdf.Document("file_example_TIFF_10MB.pdf");
			  ImagePlacementAbsorber abs = new ImagePlacementAbsorber();		
			  for (Object imagePlacement : abs.getImagePlacements())
			  	ImagePlacement placement = (ImagePlacement) imagePlacement;
	System.out.println(" Image details after conversion ");		  	

System.out.println(“image width:” + placement.getRectangle().getWidth());
System.out.println(“image height:” + placement.getRectangle().getHeight());
System.out.println(“image horizontal resolution:” + placement.getResolution().getX());
System.out.println(“image vertical resolution:” + placement.getResolution().getY());


output :

out put :
Image details before conversion
image width:1950
image height:1301
image horizontal resolution:72.00900268554688
image vertical resolution:72.00900268554688
Image details after conversion
image width:1949.0
image height:1300.0
image horizontal resolution:72
image vertical resolution:72
file_example_TIFF_10MB.zip (3.6 MB)


I can observe the difference in exported output. A ticket with ID IMAGINGJAVA-1803 has been created in our issue tracking system to investigate and resolve the issue. We will share the feedback with you as soon as the issue will be addressed.


We have investigated the root cause of issue on our end. The DPI in TIFF image and in PDF document looks different indeed. This is because of fact that in Aspose.Imaging DPI is measured using floating point numbers (72.00900268554688 for instance). But in case of Aspose.PDF, the DPI is measured using integral numbers. So, it means DPI value of 72.00900268554688 is rounded to 72. Thus because of this you are observing the difference.


Can we close this issue on our end based on the feedback that we have shared or there is any thing else that I may help you with.

The issues you have found earlier (filed as IMAGINGJAVA-1803) have been fixed in this update.