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);