Issue resizing PDF document

If I have a pdf document with pages that are set to 90, -90, 270 or -270 rotation, and I use the PdfEditor object to make sure every page is A4, those rotated pages get changed to look like they are landscape.

How can I use PdfEditor and get it to treat the pages in the shown orientation? Or remove the rotation value from each page (but keep how they are displayed)?

Below is the code that I am using to do the resize and a couple of files area attached (the original PDF with the resize applied and the one with the resize applied)

Thanks in advance

PdfFileEditor pfe = new PdfFileEditor();
pfe.ResizeContents(PdfDocument, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Width, PageSize.A4.Height));

With Resize.pdf (79.0 KB)
Without Resize.pdf (76.7 KB)

@gregglinnell

We tried to use following code snippet to set Page dimensions and remove rotation, but it also changed the content direction.

string inputFile = dataDir + @"Without Resize.pdf";
string outFile = dataDir + @"outputExample_out.pdf";
Document doc = new Document(inputFile);
foreach (Page page in doc.Pages)
{
 //page.Rotate = Rotation.None; //if use this then content is flipped
 page.SetPageSize(PageSize.A4.Width, PageSize.A4.Height);
}
doc.Save(outFile);

Therefore, we have logged an issue as PDFNET-47929 in our issue tracking system. We will further look into details of it and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thanks Asad. That has actually helped, as it has led me to try this, which has sorted my issue:

        foreach (Page page in buildBundlePdfDocument.Pages)
        {
            if (page.Rotate == Rotation.on90 || page.Rotate == Rotation.on270)
                page.SetPageSize(PageSize.A4.Height, PageSize.A4.Width);
            else
                page.SetPageSize(PageSize.A4.Width, PageSize.A4.Height);
        }
1 Like

@gregglinnell

It is good to know that your issue has been sorted out. Please keep using our API and in case you need further assistance, please feel free to let us know.