Free Support Forum -

Preserve resolution of TIFF files


i have another problem.
I want to add to pdf tif files with different resolution, and the resolution should be preserved.
For now, small tif are scaled to pdf page size.

Please provide me solution for this problem.


Thanks for contacting support.

You may please set page height and width according to source image dimensions. Please check following code snippet in order to achieve what you require:

var pdf = new Aspose.Pdf.Document();
var pdfImageSection = pdf.Pages.Add();
FileStream stream = new FileStream(dataDir + "30014201805102000004_13.tiff", FileMode.Open);
var image = new Aspose.Pdf.Image { ImageStream = stream };
image.IsApplyResolution = true;
var bmp = new System.Drawing.Bitmap(stream);
pdfImageSection.PageInfo.Width = bmp.Width;
pdfImageSection.PageInfo.Height = bmp.Height;
// remove extra white space in four corners by setting page margin information
pdfImageSection.PageInfo.Margin.Left = pdfImageSection.PageInfo.Margin.Right = pdfImageSection.PageInfo.Margin.Top = pdfImageSection.PageInfo.Margin.Bottom = 0f;
pdf.Save(dataDir + "output.pdf"); 

In case of any further assistance, please feel free to contact us.

thank you for answer.
Solution works.