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

Free Support Forum - aspose.com

Resizing crops top of file

I am trying to resize a pdf down to page letter size based on some of the examples I have found online. When I do it for this specific file (before.pdf) though its cropping off the top of the file instead of scaling down to fit on the new page.

Document document = new Document(“before.pdf”);

PdfFileEditor pdfEditor = new PdfFileEditor();

Weird thing is I take the exact same page of the pdf but greyscaled (before_works.pdf) prior to resize, and it works just fine.

examples.zip (105.1 KB)



We were able to observe similar issue in our environment while testing the scenario with Aspose.PDF for Java 19.5. We have logged it as PDFJAVA-38655 in our issue tracking system for the sake of correction. We will further look into details of this issue and keep you informed with its rectification status. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thank you! If there are any workarounds for this bug I would be interested in trying them out in the interim.


We are afraid any workaround may not be available prior investigations. We will let you know once further investigations will be made into this ticket. Please be patient and spare us little time.

Hey Farhan,

Was just wondering if you guys had any sort of timetable on a fix or workaround, or if you have had time to look at the issue anymore than when it was originally logged. We have some functionality going out in our next release that depends on getting these sizes correct. We are trying to get out ahead enough in case we should need to completely scrap using Aspose for this functionality and leverage something else in order to meet our deadlines.



Thank you for getting back to us.

We would like to inform you that we have scheduled this ticket for investigations in next week so some updates will be available after its investigations. Please be patient and spare us some time.

Hi, any update? This was over 6 months ago at this time. Thanks


We regret to share that issue has not been resolved yet due to other pending issues. We will surely inform you as soon as some certain news is available about its resolution or ETA. Please spare us some time.

We apologize for the inconvenience.


We have further investigated the ticket which was earlier logged. The structure of the current document is broken and after opening and save the document in Adobe Acrobat is normalized and worked properly. Presumably the problem is the incorrect storage of font data in Gnostice PDFOne library that was used for producing this document.

The document could be fixed in Aspose.PDF by changing any one text fragment (that leads to recreating all structure). The code snipped below could be used:

Document document = new Document(dataDir + "before.pdf");

TextFragmentAbsorber absorber = new TextFragmentAbsorber();

for (TextFragment textFragment : absorber.getTextFragments()) {            
    textFragment.setText(textFragment.getText()); // Nothing is really changed

PdfFileEditor pdfEditor = new PdfFileEditor();

pdfEditor.resizeContents(document,  com.aspose.pdf.facades.PdfFileEditor.ContentsResizeParameters.pageResize(PageSize.getPageLetter().getWidth(),
document.save(dataDir + "after_works.pdf");