如何添加粘滞便笺,在光标处插入文本,..使用带有C#的iTextSharp在现有PDF文件中添加注释? [英] How to add Sticky Notes, Insert Text at cursor, .. Annotations in existing PDF file using iTextSharp with C#?
问题描述
我想使用带有C#的iTextSharp在现有PDF文件中添加注释注释。
I want to add Annotations comment in existing PDF file using iTextSharp with C#.
请提供示例代码以在现有PDF文件中添加注释。
Please give sample code to add Annotations in existing PDF file.
这里是我的注释的PS脚本:
Here PS Script for my Annotation:
[/Contents (My Text contents) /Rect [100 600 150 550] /SrcPg 1 /Title (My Title text) /Color [0 0 1] /Subtype /Caret /ANN pdfmark
推荐答案
iText(夏普)示例 TimetableAnnotations1.java / TimetableAnnotations1.cs < iText in Action - 2nd Edition 第7章中的/ a>显示了如何向现有PDF添加注释。
The iText(Sharp) example TimetableAnnotations1.java / TimetableAnnotations1.cs from chapter 7 of iText in Action — 2nd Edition shows how to add annotations to existing PDFs in general.
中心代码是(在C#示例中):
The central code is (in the C# example):
rect = GetPosition(screening);
annotation = PdfAnnotation.CreateText(
stamper.Writer, rect, movie.MovieTitle,
string.Format(INFO, movie.Year, movie.Duration),
false, "Help"
);
annotation.Color = WebColors.GetRGBColor(
"#" + movie.entry.category.color
);
stamper.AddAnnotation(annotation, page);
其中压模
是 PdfStamper
处理您的PDF文件; movie
是一个数据结构,该示例从中检索注释的标题,文本和颜色。
where stamper
is a PdfStamper
working on your PDF file; movie
is a data structure the example retrieves title, text and color of the annotation from.
PdfAnnotation
提供多个其他 Create ...
方法来创建其他类型的注释。
PdfAnnotation
offers multiple other Create...
methods to create other types of annotations.
这篇关于如何添加粘滞便笺,在光标处插入文本,..使用带有C#的iTextSharp在现有PDF文件中添加注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!