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

Free Support Forum - aspose.com

Shrink Pages to Letter size

Hi,

I am using Aspose.Net for flattening the pdf. But I have new request to change the pdf size ( i mean dimensions)

My page is 8.5 * 14

I want to change it Letter size ( 8.5 * 11) with out losing data. I tried different approaches but its cutting off the data

Please help me Asap.

Thanks and appreciate you.

Pradeep.

Hi Pradeep,


Thanks for your inquiry. To accomplish your requirement, initially you may resize contents of your page and then change the page size accordingly. It will help you to resize page without lose of data.

Please feel free to contact us for any further assistance.

Best Regards,

I tried that. but its not dynamic enough. we dont know what is the size of the pdf.

thi code snippet works but its nto working ofr all pdf's. The editable pdf's are failing to shrink

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filePath);

Aspose.Pdf.Facades.PdfPageEditor editor = new Aspose.Pdf.Facades.PdfPageEditor();

// bind source PDF file

editor.BindPdf(pdfDocument);

Aspose.Pdf.PageCollection pageCollection = pdfDocument.Pages;

editor.Zoom = 1f;

double height = 0;

double width = 0;

for (int i = 1; i <= pageCollection.Count; i++)

{

if (editor.GetPageSize(i).Height > height)

height = editor.GetPageSize(i).Height;

if (editor.GetPageSize(i).Width > width)

width = editor.GetPageSize(i).Width;

}

if (height > (double)E_LetterSize.Height)

{

editor.Zoom = (float)E_LetterSize.Height / (float)height;

}

else if (width > (double)E_LetterSize.Width)

{

editor.Zoom = (float)E_LetterSize.Width / (float)width;

}

editor.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;

editor.VerticalAlignmentType = Aspose.Pdf.VerticalAlignment.Center;

editor.PageSize = new Aspose.Pdf.PageSize((float)E_LetterSize.Width, (float)E_LetterSize.Height);

editor.Save(outputFilePath);

Hi Pradeep,


Thanks for your inquiry. Can you please share a sample source PDF document and desired output document as well. So we will look into it and will guide you accordingly.

Best Regards,