There are probably many ways to do this, but the one that comes to mind is to use marked content when you create your watermark.
And here's a strategy for removing marked content (I haven't reviewed the code in detail, just found it from a quick SO search): https://stackoverflow.com/questions/49576411/using-pdfbox-to-remove-optional-content-groups-that-are-not-enabled For your specific case, it may be possible to just suppress everything between the BMC and EMC operators because you can make sure you aren't inserting any content stream operators in your watermark that shouldn't be removed. K On Fri, Jan 10, 2025, 8:06 AM Stefano Berretta <stefano.berre...@caditech.it> wrote: > Hi Kevin > > Yes I'm asking about removing a watermark added using PDFBox. > > Removing arbitrary watermark is out of the scope of the project. > > Thank > > -Stefano > Il 10/01/2025 16:00, Kevin Day ha scritto: > > Are you asking about removing a watermark that you added using PDFBox? Or > are you asking about removing an arbitrary watermark (that someone else > added)? > > On Fri, Jan 10, 2025, 6:41 AM Stefano Berretta < > stefano.berre...@caditech.it> wrote: > >> Hello everybody >> >> I'm new to PDFBox. I was requested to apply a text watermark on PDFs and >> I found some examples, they're pretty easy to understand. But I'm asked >> also to remove a watermark. I'll give some details. They want that >> documents are marked as "not ready" until someone approve them. When this >> happens, the watermark has to be removed. >> >> But removing a watermark is not so simple and I could not find any >> examples. I tried to put the watermark on a layer and remove it. The layer >> was removed, but the text remained. >> >> So what approach would you suggest me? >> >> Thanks a lot >> -- >> Stefano Berretta >> >> [image: Logo Caditech] >> > -- > Stefano Berretta > > [image: Logo Caditech] > CAD.I.TECH - CAD Integration Technology s.r.l > C.so Podestà 12, 16128 Genova > Tel: 010.362.62.66 - 010.869.59.04 > Cel: 331 348 34 25 > Fax: 010.362.62.67 > SKYPE: stefano.berretta_2 > > > La presente comunicazione, con le informazioni in essa contenute e ogni > documento o file allegato, e' strettamente riservata e soggetta alle > garanzie che legano i rapporti tra le parti interessate. E' rivolta > unicamente alle persone cui e' indirizzata ed alle altre da queste > autorizzate a riceverla. Se non siete i destinatari Vi informiamo che > qualsiasi azione, copia, comunicazione, divulgazione o simili basate sul > contenuto di tali informazioni e' vietata ai sensi della legge (art. 616 > C.P., D.Lgs n. 196/2003 Codice in materia di protezione dei dati > personali). Se avete ricevuto questa comunicazione per errore, vi preghiamo > di darne immediata notizia al mittente a mezzo telefono, fax o e-mail e di > distruggere il messaggio originale e ogni file allegato senza farne copia o > riprodurne in alcun modo il contenuto. Grazie. > > This e-mail and its attachments are intended for the addressee(s) only and > are confidential and/or may contain legally privileged information. If you > have received this message by mistake or are not one of the addressees > above, you may take no action based on it, and you may not copy or show it > to anyone; please reply to this e-mail and point out the error which has > occurred. Thank you. > > > Prima di stampare questa comunicazione consideratene, per favore, > l'impatto ambientale > Please consider the environment before printing this email >