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

Free Support Forum - aspose.com

PDF dimensions too large!

I have the following code to save a TIF to a PDF, but the saved PDF is considerably larger than the original tif, zooming in to the pdf 65% seems about the correct size, also setting the compression value makes no difference on the size of the file.


Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);

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

using(var bmp = Bitmap.FromFile(input)){

pdf1.PageSetup.PageWidth = bmp.Width;
pdf1.PageSetup.PageHeight = bmp.Height;

pdf1.PageSetup.Margin.Bottom = 0;
pdf1.PageSetup.Margin.Top = 0;
pdf1.PageSetup.Margin.Left = 0;
pdf1.PageSetup.Margin.Right = 0;

sec1.PageInfo.PageWidth = bmp.Width;
sec1.PageInfo.PageHeight = bmp.Height;

sec1.PageInfo.Margin.Top = 0;
sec1.PageInfo.Margin.Bottom = 0;
sec1.PageInfo.Margin.Left = 0;
sec1.PageInfo.Margin.Right = 0;

image1.ImageInfo.FixWidth = bmp.Width;
image1.ImageInfo.FixHeight = bmp.Height;

if(bmp.Width > bmp.Height)
sec1.IsLandscape = true;
else
sec1.IsLandscape = false;
}

sec1.Paragraphs.Add(image1);

pdf1.Save(output);

Hi Andrew,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing your sample code.

Please share your template and resultant file with us. This will help us replicate your issue and identify the cause soon. Also, which version of Aspose.Pdf for .NET are you using?

Thank You & Best Regards,

Every TIF I have tried has been too large. I am using v6.3!


Thanks

Hi Andrew,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I checked your issue and noticed generated PDF is more in dimension then the original image file. However, when I converted the generated PDF back to an Image file using Adobe X, it generated the exactly same size image file (in size and dimensions) which I used to generate the PDF file. So, it seems to me that this scaling of the image (as PDF file) is in PDF viewer (i.e. Adobe Reader). Could you please check it with your template Tiff file at you end and share your results.

Sorry for the inconvenience,

How did you do the PDF to Tiff conversion?

Hi Andrew,<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>



I used Adobe X to convert PDF to Tiff to check the dimensions. You may use File
à
Save As
à Tiff to save the file to tiff
format and checked the dimension. As mentioned above, the dimensions are coming
same as the template tiff file you shared. Please do let us know in case you
need any further assistance or you are getting different results.<o:p></o:p>

<o:p> </o:p>

Sorry for the
inconvenience,