Getting watermark with java

I’m trying to check if a pdf created with Aspose has a watermark or not. I have tried different approaches but none of them worked.

Approach number one:

pdfDocument = new Document(sourceDocPath);
if (pdfDocument.getPages().get_Item(1).getWatermark() != null){ 
     System.out.println("—" + pdfDocument.getFileName());
}

The getWatermark() always returns an object, even when the pdf doesn’t have a watermark
I have also try other methods after getting the watermark and all of them return the same values, as getPosision() and getClass()

Approach number two:

Looking into the forum, I saw a solution with .Net, and I tried to do the same in java, but didn’t work:
boolean hasWatermark = false;
for (Artifact artifact : pdfDocument.getPages().get_Item(1).getArtifacts())
{
if ( artifact.getSubtype() == ArtifactSubtype.Watermark )
hasWatermark = true;
}
if (hasWatermark){
System.out.println("—" + pdfDocument.getFileName());
}
The size of pdfDocument.getPages().get_Item(1).getArtifacts() is always 0.

I’m using Aspose 18.9

Thanks

@sshortall,

Thanks for contacting support. Can you please share source file so that we may further investigate to help you out. Also please try to use Aspose.PDF latest version 19.11 on your end before sharing requested information.