Resize existing pdf pages to A4

Hi,

I want to resize existing pdf all pages to A4 size. In the existing pdf last page is larger in width as compare to other one but in the Aspose.Pdf.Document it is showing all pages size is same. Can you please check?

      Document pdfDocument = new Document("2022-02-02323D-1.pdf");

     foreach(var pdfPage in pdfDocument.Pages)
     {
        pdfPage.SetPageSize(597.6, 842.4);
     }

     pdfDocument.Save("output.pdf");

Assembly Aspose.PDF, Version=24.2.0.0
Nuget package - aspose.pdf.drawing

2022-02-02323D-1.zip (3.8 MB)

@amolm

We tried below code snippet in our environment to resize all pages to A4 paper size because last page has larger size. But we were not succeeded.

Document pdfDocument = new Document(dataDir + "2022-02-02323D-1.pdf");
Facades.PdfFileEditor pdfEditor = new Facades.PdfFileEditor();
Facades.PdfFileEditor.ContentsResizeParameters resizeParameters = new Facades.PdfFileEditor.ContentsResizeParameters()
{
    TopMargin = Facades.PdfFileEditor.ContentsResizeValue.Units(72),
    LeftMargin = Facades.PdfFileEditor.ContentsResizeValue.Units(72),
    RightMargin = Facades.PdfFileEditor.ContentsResizeValue.Units(72),
    BottomMargin = Facades.PdfFileEditor.ContentsResizeValue.Units(72),
    ContentsHeight = Facades.PdfFileEditor.ContentsResizeValue.Units(PageSize.A4.Height),
    ContentsWidth = Facades.PdfFileEditor.ContentsResizeValue.Units(PageSize.A4.Width)
};
pdfEditor.ResizeContents(pdfDocument, new int[] { 30 }, resizeParameters);
pdfDocument.Save(dataDir + "document_resized.pdf");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56828

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @asad.ali

Thanks for your reply.
Please let me know once this issue is fixed

Thanks,

1 Like

@amolm

Sure, we will keep you posted about the ticket progress within this forum thread.

Hi @asad.ali
Any update on this issue?

@amolm

We are afraid that the earlier logged ticket could not be resolved due to other issues in the queue logged prior to it. We will surely inform you once we make some progress towards ticket resolution. Please spare us some time.

We are sorry for the inconvenience.