NullPointerException when creating com.aspose.pdf.Document object from PDF with digital signature

When creating a com.aspose.pdf.Document object passing an InputStream of a signed PDF we get a NullPointerException.

The code:

            ......
	InputStream binaryInputStream;
	try {
		binaryInputStream = input.asInputStream(getCharset());
	} catch (IOException e1) {
		throw new PipeRunException(this,
					getLogPrefix(session) + "cannot encode message using charset [" + 
                                            getCharset() + "]", e1);
	}

	try {
		Document doc = new Document(binaryInputStream);
            .....

The output:

Caused by: java.lang.NullPointerException
at com.aspose.pdf.internal.l8f.l0v.l0h(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l8f.l0v.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l8f.l0v.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l6t.lf.lI(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l8f.l0t.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l6t.lf.lb(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l0k.l0if.lf(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.internal.l0k.l0if.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.ADocument.lI(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.ADocument.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.ADocument.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at com.aspose.pdf.Document.(Unknown Source) ~[aspose-pdf-19.1.jar:19.1]
at nl.nn.adapterframework.extensions.aspose.pipe.AmountOfPagesPipe.doPipe(AmountOfPagesPipe.java:60) ~[classes/:?]

Using Aspose.PDF versie 19.1 for Java.
Java version = 1.8.0_231

Request your help in solving this.

@sojourn999

Would you please also share your sample PDF with us as well. We will test the scenario in our environment and address it accordingly.

We are not able to reproduce the error with any signed PDF. We are not allowed to share the customer signed PDF that does cause the error because of security reasons, so this topic can be closed.

@sojourn999

It seems like the issue is related only to some specific type of PDF and in order to further investigate the scenario, we need that particular file. If you cannot share it publicly, we can offer you an option of sending it in a private message. You can click over username and press Blue Message button to compose a private message. This way the file will only be accessed to Aspose Staff.

@asad.ali

Hi, I have a similar problem in the same jar. When I try to initialize a document with a pdf file I get the same stacktrace. Here I upload the test files I used to reproduce the issue.

adoc.pdf (25.1 KB)
mdoc.pdf (25.1 KB)

@alisihab

Have you tried using Aspose.PDF for Java 22.1 to open the PDF file? We have used it and did not notice any issue. Please try to use the latest version and let us know in case you still notice any issue.