When Resizing image using Aspose PDF, original content is lost

Hi there

I have a number of pdfs supplied by our customer which are A0/A1 pdfs and I am using Aspose PDF to resize these images to A3 . When I look at new A3 sized PDF , the original content has been lost in the resized file.

This is a major issue and I am not sure if this is a bug in Aspose .PDF or whether I am using the wrong command

The version I am using is Apose PDF v22.11.0.0

Here is the function that I am calling passing in the source file name , papersize = 8 (A3)
I can send you the files if required , so please let me know which email to send those to.

private void ResizeDocument(string inputFileName, int paperSize, string watermarkText, string captionText)
{
try
{
bool bFoundPapersize = true;
PdfPageEditor pEdit = new Aspose.Pdf.Facades.PdfPageEditor();
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(inputFileName))
{
pEdit.BindPdf(doc);

                float capionFontSize = 12;
                float watermarkFontSize = 12;
                float headerTopMargin = 0;
                for (int i = 0; i < doc.Pages.Count; i++)
                {
                    // get the page size 
                    var pageSize = pEdit.GetPageSize(i + 1);
                    PdfFileEditor pfe = new PdfFileEditor();
                    switch (paperSize)
                    {
                        case 127: //A0
                        case 261:
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A0.Height, PageSize.A0.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A0.Width, PageSize.A0.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 129: // "A1"
                        case 262:
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A1.Height, PageSize.A1.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A1.Width, PageSize.A1.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 66: // "A2"
                        case 263:
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A2.Height, PageSize.A2.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A2.Width, PageSize.A2.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 8: // "A3"
                        case 264:
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A3.Height, PageSize.A3.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A3.Width, PageSize.A3.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 9: // "A4"
                        case 265:
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Height, PageSize.A4.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A4.Width, PageSize.A4.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 11: // "A5"
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A5.Height, PageSize.A5.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A5.Width, PageSize.A5.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        case 70: // "A6"
                            if (pageSize.IsLandscape)
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A6.Height, PageSize.A6.Width));
                            }
                            else
                            {
                                pfe.ResizeContents(doc, new int[] { i + 1 }, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(PageSize.A6.Width, PageSize.A6.Height));
                            }
                            capionFontSize = 12;
                            watermarkFontSize = 12;
                            headerTopMargin = 12;
                            break;
                        default:
                            bFoundPapersize = false;
                            break;
                    }
                }
                doc.Save(inputFileName);
                pEdit.Close();
                pEdit.Dispose();                    
            }
        }
        catch (Exception ex)
        {

        }

@Gurbinder

Would you kindly share your sample source PDF for our reference? We will test the scenario in our environment using the latest version of the API and share our feedback with you.

Hi there

Attached are 7 files that I have added try resizing them to A3 and compare the results from the original file to the converted file.

SCAN946.PDF (121.0 KB)
SCAN947.PDF (159.0 KB)
SCAN948.PDF (150.2 KB)
SCAN949.PDF (178.4 KB)
SCAN950.PDF (150.2 KB)
SCAN951.PDF (159.0 KB)
scan952.PDF (238.1 KB)

@Gurbinder

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-54902

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 there
Thanks for confirming that this is an issue with Aspose PDF. As this is for a production customer issue, are there any workarounds that you can suggest to get around this issue

Regards
Gurbinder

@Gurbinder

We are afraid that we cannot share any workaround at the moment without completing our analysis against this scenario. As soon as the ticket is investigated, we will be able to share some feedback. We will look into details of this issue on first come first serve basis and let you know in case of any update. Please be patient and spare us some time.

We are sorry for the inconvenience.