I am trying to create a plugin that redacts words in the same fashion as the ones you are creating manually. But I am having a hard time figuring out how this can be done. I have played around with PDRedactParams and PDApplyRedactionParams but with no luck. It always create the redaction with my "custom" values for color etc.
So what I am basically asking is how to programatically create redaction annotations with the same parameters as used in "Properties" for redaction annotations in Acrobat DC?
I'm not completely solid on this point, but I believe that all the Redact Annot Properties in the Properties dialog are also entries in the Cos Dict for the Annot, so you can set them to whatever you want at the Cos level. You can test this by making changes to the redact properties and then examining the cos structure. You can also make changes to the Cos structure and then see what the properties dialog shows (if you have PDF CanOpener this is an easy task) You should also read the Redact annot section of the PDF spec.
I also believe, but haven't tested, that you can make the final redact appearance match whatever you want by creating your own RO stream.
But uhh..it sounds complicated. I have just started out with the SDK, so I am unfortunately not familiar with everything yet. Looks like I have some homework to do regarding the Cos Layer
My initial problem was that when I added the redact annotation (before applying it with PDDocApplyRedactions), it would not show anything unless I hovered the mouse over it. I thought I should have the same box and rectangle like you get when applying it manually. Thats why I thought I did something wrong and I should have gotten the same with my code.
In order for the Redact Annotation to display something it must have an appearance. The appearance is a stream object containing a set of drawing operators. Its a standard PDF content/xobject stream. In fact, the redact AP dict has 3 appearance entries, Normal (what you see on the page), Rollover, and Mouse Down. I don't believe that these are setup right away by the creation of the annot from the SDK. You have to force Acrobat to make them. I seem to remember there was a flag, or Annot dict entry that tells Acrobat an annot appeance needs to be created, but I don't remember exactly what is. You'll have to read the spec on Annotations.
Learning the SDK is a big hill to climb because to understand it, you also need to understand the PDF spec. But when you start understanding how a PDF is put together, the SDK will become easy.
Than you very much Thom. This has been very helpful. If someone has a book or web site to recommend to speed up the learning process it would be appreciated.
Thom, after a lot of hairs pulled out I finally figured it out. You pointed me to the right direction with the Cos objects. To show the redact annotations I had to create a Cos array (color) for the object of "OC" and apply it to the annotation. Now I have a rectangle around it. Next step would be to figure out the properties dialog. Looks like your PDF CanOpener are the right tool for this