We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PdfFileEditor ResizeContents method breaks pdf file

Hello!

In our application we allow user to upload different files and then generate pdf file with all the uploaded file attached (very simplified).
While generating files I’m using PdfFileEditor and ResizeContents method to manually create “footer” so I can place there some information like page number, file name, etc.
This is my code:

var fileEditor = new PdfFileEditor();
        var parameters = new PdfFileEditor.ContentsResizeParameters(
            PdfFileEditor.ContentsResizeValue.Units(10),
            null, 
            PdfFileEditor.ContentsResizeValue.Units(10), 
            PdfFileEditor.ContentsResizeValue.Units(10), 
            null, 
            PdfFileEditor.ContentsResizeValue.Units(40)
            );

foreach (var doc in documentsInfo)
        {
            fileEditor.ResizeContents(doc.Value.Document, parameters);
        }

For almost every file this works and I’m getting result similar to this:

But for one file it completely breaks the file, and I’m getting this result:

This happens for every page of this document, but only this document. Any other file (pdf, doc, image, anything) works brilliant.
Original page:

Am I doing something wrong or is it problem with this one document.
Nevertheless I need to make it work for every document.

@Nuggosh

Thanks for contacting support.

Sometimes issue may be related with the specific document, depending upon the structure and complexity of that document. It would really be appreciated if you can please share your PDF document with us, so that we can test the scenario in our environment and address it accordingly.

christmas_Carol_T.pdf (361.1 KB)
This is a problematic file

@Nuggosh

Thanks for sharing sample document.

I have tested the scenario and managed to replicate the issue which you have mentioned. It seemed that the issue is related with this specific document, as I have also tried to process some of my sample document(s) and it went well. Therefore, I have logged an issue as PDFNET-43195 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thanks,

Do you have any solution how to detect specific files before or after resize?
I would be able to skip resizing for those files.

Edit:

I’ve fount problem with pages CropBox property, values there are simply wrong. So for now I;m detecting if CropBox has valid values, then I’m resizing it.
I hope it will help you

@Nuggosh

Thanks for acknowledging us.

We have shared the details, which you have shared, with the respective team and it will really be helpful in investigating and resolving the issue. As soon as we have some feedback regarding resolution progress, we will let you know. Please spare us little time.

We are sorry for the inconvenience.