Pdf black out text pdf#If you're not careful, you risk ending up with a so-called PDF Blackout Folly. You can still select the text and copy/paste it. The approach to add opaque rectangles doesn't apply redaction: the redacted content is merely covered, not removed. The second question requires the itext-xtra.jar (an extra jar shipped with iText) and you need at least iText 5.5.4. Pdf black out text how to#You can use the Put() method to add all the other keys you need for the annotation.Īnswer 2: How to "apply" a redaction annotation You want a Redact annotations, so you'll need something like this: PdfAnnotation annotation = new PdfAnnotation(writer, rect) This is a manual way to create a text annotation. When created in Acrobat, this is always set to "Redact"įloat fillColor = ", text))Īnnotation.Put(PdfName.NAME, new PdfName(text)) PdfAnnotation annotation = new PdfAnnotation(stamper.Writer, rect) Īnnotation.Put(PdfName.SUBTYPE, new PdfName("Redact")) Īnnotation.Title = "My Author" // Title = authorĪnnotation.Put(new PdfName("Subj"), new PdfName("Redact")) // Redaction "Subject". Using (PdfStamper stamper = new PdfStamper(pdfReader, new FileStream(newFileName, FileMode.OpenOrCreate))) PdfReader pdfReader = new PdfReader(stream) using (Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) It does not apply the redactions in the end but it creates valid redactions which are properly shown within Acrobat and can then be applied manually. I want to create redaction annotations and eventually apply redaction.Īs I finally got around to create a working example I wanted to share it here. The only other option I found so was was to create black rectangles as explained here, but that doesn't remove the text (it can still be selected). Many PDFs also contains metadata, information about. In iTextSharp I can create simple text annotations like this PdfAnnotation annotation = PdfAnnotation.CreateText(stamper.Writer, rect, "Title", "Content", false, null) Hence, blacking out just the scanned text will remove it visually, but the hidden text is still there. (I haven't be able to apply them though as annot.Perform(avDoc) does not seem to work. With the Acrobat SDK the code would like simply like this: AcroPDAnnot annot = page.AddNewAnnot(-1, "Redact", rect) as AcroPDAnnot So I was wondering if it's possible to create those in iTextSharp as well? Is there any way to implement PDF redaction using iText? Working with the Acrobat SDK API I found that redactions also just seem to be annotations with the subtype "Redact".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |