TIFF to PDF - height and width calculations

I create an Aspose.Pdf.Generator.Image (v8.3) like so:<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

var image = new Image( section )

{

ImageInfo =

{

ImageStream = source.OpenStream(),

ImageFileType = ImageFileType.Tiff,

IsAllFramesInNewPage = true,

}

};

However, image.ImageHeight and image.ImageWidth are still 0. How do I get actual the height and width to populate?


Hi John,


Thanks for contacting support.

As per my understanding, you are getting dimensions of TIFF image being placed inside PDF document ? Please note that if you try to get the image dimensions before the PDF file is saved, the result will always be 0. However if you get the Image dimensions after the PDF file is saved, you can have correct value.

In case you need to get the mage dimensions before the file is saved, you may consider using Bitmap object to get the image dimensions. Also please note that once the PDF file is saved and you try to get the image dimensions using Image.ImageInfo object, the dimensions in which image is placed inside the PDF document, will be displayed. Please take a look over following code snippet.

[C#]

//Set the path of image file<o:p></o:p>

image1.ImageInfo.File = "C:/pdftest/Page1.tif";

//Set the type of image using ImageFileType enumeration

image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

// print ImageInfo height information

Console.WriteLine("Image Height - " + image1.ImageInfo.FixHeight);

// load the image into BMP object

Bitmap bmp = new Bitmap("C:/pdftest/Page1.tif");

// print the Height of image loaded inside BMP object

Console.WriteLine("BMP Image Height - " + bmp.Height);

//Save the Pdf

pdf1.Save("c:\\pdftest\\Converted_test.pdf");

// display height of Image object after saving PDF file

Console.WriteLine("Image
Height - "
+ image1.ImageInfo.FixHeight);



In case I have not properly understood your requirement or you have any further query, please feel free to contact.