Invalid parameters count for g operator

Hi Team,

When we use the following Java code:

    public static void splitPdfPages(String inputPdfPath, String outputDir) {
        Document pdfDocument = null;
        Document currentDocument = null;
        try {
            pdfDocument = new Document(inputPdfPath);
            currentDocument = new Document();
            for (int i = 1; i <= pdfDocument.getPages().size(); i++) {
                currentDocument.getPages().add(pdfDocument.getPages().get_Item(i));
                String tmpOutFile = "tmp_" + i + ".pdf";
                String tmpOutPath = Paths.get(outputDir, tmpOutFile).toString();
                **currentDocument.save(tmpOutPath);**
                currentDocument.close();
                currentDocument = new Document();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (pdfDocument != null) {
                pdfDocument.close();
            }
            if (currentDocument != null) {
                currentDocument.close();
            }
        }
    }

to split this PDF into single page PDF files:

But when it split to page 188, this line of code currentDocument.save(tmpOutPath); will throw an exception of Invalid parameters count for g operator:

class com.aspose.pdf.internal.ms.System.lh: Invalid parameters count for g operator. com.aspose.pdf.operators.SetGrayStroke.<init>(Unknown Source) com.aspose.pdf.internal.l4v.lk.lI(Unknown Source) com.aspose.pdf.Operator.lI(Unknown Source) com.aspose.pdf.DefaultAppearance.lI(Unknown Source) com.aspose.pdf.DefaultAppearance.<init>(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.l0u(Unknown Source) com.aspose.pdf.Annotation.lh(Unknown Source) com.aspose.pdf.AnnotationCollection.lf(Unknown Source) com.aspose.pdf.ADocument.preSave(Unknown Source) com.aspose.pdf.ADocument.lj(Unknown Source) com.aspose.pdf.ADocument.lf(Unknown Source) com.aspose.pdf.ADocument.lf(Unknown Source) com.aspose.pdf.ADocument.save(Unknown Source) com.aspose.pdf.Document.save(Unknown Source)

The version of aspose-pdf is 24.3, we wonder if this can be fixed in a future version? Or how can we avoid this error?

@Rich_Yu

We tested the scenario in our environment using 24.9 version of the API and could not replicate the issue. Please try with the latest version and let us know if you still face any issues.

Got it, I tested it with 24.9 version and could not replicate the issue as well, thanks!

@Rich_Yu

Its nice to know that your issue has been resolved after using 24.9 version of the API. Please keep using our API and feel free to inform us by creating a new topic in case you need further assistance.