I'm using Adobe PDF library (C++ Interface) and have been trying to remove the watermarks on an existing PDF for a while.
To add a watermark I have used the PDDocAddWatermarkFromText
method, but I would need to remove the previously existing watermarks on the file.
I accomplished the task when the Watermark is added as an Annotation, but this will not cover all the possible cases, as it seems they can be added also as background Objects. Would need to know how these background objects can be removed from the file.
Thanks for help!
Watermarks will typically be the last element of the page's content stream, Backgrounds will the first element of the content stream. So I would check if the first or last element is a PDEForm. And if it is, I would then check if the PDEFormCosObj has a PieceInfo dictionary entry. The PieceInfo dictionary may indicate if it is a WaterMark or a Background.
Otherwise, you might need to analyze the content of that PDEForm for watermark-like properties (e.g. is it a Text Element with a single textRun? Does the Form|Text|TextRun's matrix indicate any rotation?)