Hi,
The input pdf, which has two a4 pages, and a third a3 landscape page was already attached.
Regarding the code it is not working, but we have a function that will receive a binary pdf, and it will receive a pagesize ‘A4’ tag, if this is used, it should return a pdf where all pages are in A4 format.
So the third page, should be rotated, and scaled to fit on a A4 portrait page.
public void MssPDF_DefinePageSize(byte[] ssSourcePDF, string ssPageSize, out byte[] ssResizedPDF, out string ssErrorMessage)
I attached the code with several attempts to achieve this:
My first guess and easy to explain:
#atempt1:
/create PdfPageEditor object
PdfPageEditor pEdit = new PdfPageEditor();
//bind pdf file
pEdit.BindPdf(inputFileMemStream);
//PageSize property of the PdfPageEditor class
if (ssPageSize.ToUpper().Equals(“A4”))
{
pEdit.PageSize = Aspose.Pdf.PageSize.A4;
ssErrorMessage = string.Empty;
}
else {
ssErrorMessage = “The requested page format is unknown.”;
}
MemoryStream temp = new MemoryStream();
pEdit.Save(temp);
ssResizedPDF = temp.ToArray();
pEdit = null;
This do not scale or rotate, the a3 page, so i got a A4 pdf but the the A3 page cut.
#atemp2 this was not to solve the issue, but to check that the print method with autoresize and autorotate produces a good a4 pdf without cuts… it was something like this that i pretend as a result. (but I don’t want to print, I want a pdf as a result)
#atempt 3, I tried to use isLandscape as a way to detect that i am with a landscape page, that i need to rotate… and scale (the a3 page, is not detected as Landscape), and i do not now very well how to scale.
#atempt 4, by the size of the page, i tried to understand that i am on my landscape a3 page, that o need to rotate… and i tried to use pdfEditor ResizeContents to make the resize for the A4 pages.
Well, What should be the approach and the code to ensure that at the end, all pages at the end are in A4 portrait format.