Change PDF Annotation properties using iTextSharp C#

余生颓废 提交于 2020-01-04 06:11:15

问题


Hi I am adding a caret annotation to an already existing PDF using iTextSharp in C#.

Now I want to change some of the annotation's properties, such as Opacity of color and Locked.


回答1:


Suppose that you have a PdfAnnotation object. This is a class that extends PdfDictionary.

To lock the annotation defined by this annotation dictionary, you need to set the PdfAnnotation.FLAGS_LOCKED flag, for instance with the setFlags() method:

annot.setFlags(PdfAnnotation.FLAGS_LOCKED);

Note that using this method will override the flags that were already defined before.

As for the opacity, that's define by the ca entry of the annotation dictionary.

annot.put(PdfName.ca, new PdfNumber(0.27));

You mention iText as well as iTextSharp, my snippets are lines of Java code. You'll need to apply small changes to the methods if you want to use them in C# code.



来源:https://stackoverflow.com/questions/19538354/change-pdf-annotation-properties-using-itextsharp-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!