Method PdfFileEditor.resizeContentsWithNormalization fails with some PDF files (190.8 KB)

Aspose Team,
We use the Aspose PDF java package to resize single page PDF files. We found out that the method PdfFileEditor.resizeContentsWithNormalization fails with some PDF files from version 22.4. The error is as follows:

class Specified argument was out of the range of valid values.
Parameter name: Parameter name: index Source)
com.aspose.pdf.internal.l4if.l0h.lf(Unknown Source)
com.aspose.pdf.operators.SetRGBColor.fromCommand(Unknown Source)
com.aspose.pdf.Operator.(Unknown Source)
com.aspose.pdf.operators.SetColorOperator.(Unknown Source)
com.aspose.pdf.operators.SetRGBColor.(Unknown Source) Source)
com.aspose.pdf.Operator.lI(Unknown Source)
com.aspose.pdf.DefaultAppearance.lI(Unknown Source)
com.aspose.pdf.DefaultAppearance.(Unknown Source)
com.aspose.pdf.FreeTextAnnotation.getDefaultAppearanceObject(Unknown Source)
com.aspose.pdf.FreeTextAnnotation.lf(Unknown Source)
com.aspose.pdf.Annotation.lI(Unknown Source)
com.aspose.pdf.Annotation.updateAppearances(Unknown Source)
com.aspose.pdf.Annotation.changeAfterResize(Unknown Source)
com.aspose.pdf.facades.APdfFileEditor.resizeContents(Unknown Source)
com.aspose.pdf.facades.PdfFileEditor.resizeContents(Unknown Source)
com.aspose.pdf.facades.APdfFileEditor.resizeContentsWithNormalization(Unknown Source)
com.aspose.pdf.facades.PdfFileEditor.resizeContentsWithNormalization(Unknown Source)

Following is the sample code and attached are the sample files. Note that there are 4 pdf files. Two of them (tmp_6.pdf and tmp_7.pdf) work and the other two (tmp_8.pdf and tmp_9.pdf) fail.
The operating system is Ubuntu 20.04. Java version is 11. Aspose PDF java packages is 22.6.

public class Resize_21 {

public static void main(String[] args) {

    Document pdfDocument = null;
    try {
        String inPath = "path-to-the-sample-file";
        float horizontalMargin = 4.25f;
        float maxHeightForUpperStamping = 11f;
        float maxHeightForBottomStamping = 11f;

        PdfFileEditor.ContentsResizeParameters parameters = new PdfFileEditor.ContentsResizeParameters(


        pdfDocument = new Document(inPath);
        PdfFileEditor editor = new PdfFileEditor();
        editor.resizeContentsWithNormalization(pdfDocument, parameters);

   } catch (Exception ex) {
   } finally {
       if (pdfDocument != null) {



We were able to replicate the exception in our environment while using Aspose.PDF for Java 22.11. Therefore, an issue as PDFJAVA-42348 has been registered in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

@asad.ali can you please let us know if you have any updates on this issue?


The issue has recently been logged in our issue tracking system and will be investigated on a first come first serve basis. We will surely inform you once we make some significant process towards issue resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-42348) have been fixed in Aspose.PDF for Java 23.1.