Last active
December 28, 2022 06:59
-
-
Save lazytiger/58d04ea24ce13ed35c3258993e0607ec to your computer and use it in GitHub Desktop.
How to remove watermark created by spire.pdf?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PDDocument document = PDDocument.load(new File("files/test.pdf")); | |
for (PDPage page : document.getPages()) { | |
PDResources resources = page.getResources(); | |
resources.getCOSObject().removeItem(COSName.PATTERN); | |
} | |
document.save("files/1.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spire.pdf usually use a PDAbstractPattern to create a watermark, so If we delete the pattern, the watermark won't be rendered.