Skip to main content
richardg96106453
Participant
March 12, 2016
Question

Setting font in existing Redact annotation

  • March 12, 2016
  • 2 replies
  • 566 views

My goal is for my addin to get the font from underlying pdf text, and update a redact annotation to use that font.

I now have a font CosObj created from the text using PDEFontGetCosObj.

I also have the redact annotation CosObj created using PDAnnotGetCosObj.

I'm stuck on how to get the font into the redact annotation so that it uses that font. Do I need to use the cos dictionary get and put methods? Ie get key value from the one dictionary, then update the font key value of the other? How do I find out the keys they have?

Am I on the right track?

Any help is appreciated.

Rick

Message was edited by: Richard Grear

This topic has been closed for replies.

2 replies

Legend
March 23, 2016

‌Adobe Serif MM is a substitution font not the one used in the PDF. Look deeper.

Inspiring
March 14, 2016

The way I work on issues like this is to do this manually in Acrobat first and then look at the resulting PDF. Working at the COS level is possible, but wherever possible use a higher level method such as the PD or PDE interfaces. If you aren't already using it WindJack PDFCanOpener is a great tool that will not only allow you to browse the internals of PDF files, but also edit the internals. I am not affiliated with them, but use this tool almost daily. I am not very familiar with the Redact annotation, but most annotations have an appearance dictionary and also another entry that will specify the font to use such as the /DA dictionary entry in form fields. Within the appearance dictionary there should be a Resource dictionary that holds the information on the font.

richardg96106453
Participant
March 23, 2016

Thanks

I've opted to enumerate the fonts in the document using PDDocEnumFonts(). And then I can set the textFont of the annotations from one the fonts returned.

However the fonts returned from PDDocEnumFonts and also PDDocEnumLoadedFonts aren't any that I'm seeing in the document. For example it's returning NewBaskerville-Roman and GillSans-Bold. Actual font used in the document text is mainly Adobe Serif MM.

Perhaps Adobe Serif MM is being detected but I'm not accessing it?