本文整理匯總了C#中iTextSharp.text.pdf.PdfWriter.AddAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfWriter.AddAnnotation方法的具體用法?C# PdfWriter.AddAnnotation怎麽用?C# PdfWriter.AddAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfWriter
的用法示例。
在下文中一共展示了PdfWriter.AddAnnotation方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnGenericTag
/**
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onGenericTag(
* com.itextpdf.text.pdf.PdfWriter,
* com.itextpdf.text.Document,
* com.itextpdf.text.Rectangle, java.lang.String)
*/
public override void OnGenericTag(PdfWriter writer,
Document document, Rectangle rect, string text)
{
PdfAnnotation annotation = new PdfAnnotation(writer,
new Rectangle(
rect.Right + 10, rect.Bottom,
rect.Right + 30, rect.Top
)
);
annotation.Title = "Text annotation";
annotation.Put(PdfName.SUBTYPE, PdfName.TEXT);
annotation.Put(PdfName.OPEN, PdfBoolean.PDFFALSE);
annotation.Put(PdfName.CONTENTS,
new PdfString(string.Format("Icon: {0}", text))
);
annotation.Put(PdfName.NAME, new PdfName(text));
writer.AddAnnotation(annotation);
}
示例2: OnGenericTag
/**
* @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
*/
public override void OnGenericTag(PdfWriter writer, Document document,
Rectangle rect, String text) {
rect.Bottom = rect.Bottom - 3;
PdfFormField field;
genericChunkFields.TryGetValue(text, out field);
if (field == null) {
TextField tf = new TextField(writer, new Rectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)), text);
tf.FontSize = 14;
field = tf.GetTextField();
}
else {
field.Put(PdfName.RECT, new PdfRectangle(rect.GetLeft(padding), rect.GetBottom(padding), rect.GetRight(padding), rect.GetTop(padding)));
}
if (parent == null)
writer.AddAnnotation(field);
else
parent.AddKid(field);
}
示例3: AddPushButton
// ---------------------------------------------------------------------------
/**
* Create a pushbutton for a key
* @param writer the PdfWriter
* @param rect the position of the key
* @param btn the label for the key
* @param script the script to be executed when the button is pushed
*/
public void AddPushButton(PdfWriter writer, Rectangle rect,
String btn, String script)
{
float w = rect.Width;
float h = rect.Height;
PdfFormField pushbutton = PdfFormField.CreatePushButton(writer);
pushbutton.FieldName = "btn_" + btn;
pushbutton.SetWidget(rect, PdfAnnotation.HIGHLIGHT_PUSH);
PdfContentByte cb = writer.DirectContent;
pushbutton.SetAppearance(
PdfAnnotation.APPEARANCE_NORMAL,
CreateAppearance(cb, btn, BaseColor.GRAY, w, h)
);
pushbutton.SetAppearance(
PdfAnnotation.APPEARANCE_ROLLOVER,
CreateAppearance(cb, btn, BaseColor.RED, w, h)
);
pushbutton.SetAppearance(
PdfAnnotation.APPEARANCE_DOWN,
CreateAppearance(cb, btn, BaseColor.BLUE, w, h)
);
pushbutton.SetAdditionalActions(
PdfName.U,
PdfAction.JavaScript(script, writer)
);
pushbutton.SetAdditionalActions(
PdfName.E, PdfAction.JavaScript(
"this.showMove('" + btn + "');", writer
)
);
pushbutton.SetAdditionalActions(
PdfName.X, PdfAction.JavaScript(
"this.showMove(' ');", writer
)
);
writer.AddAnnotation(pushbutton);
}
示例4: AddTextField
// ---------------------------------------------------------------------------
/**
* Add a text field.
* @param writer the PdfWriter
* @param rect the position of the text field
* @param name the name of the text field
*/
public void AddTextField(PdfWriter writer, Rectangle rect, String name)
{
PdfFormField field = PdfFormField.CreateTextField(
writer, false, false, 0
);
field.FieldName = name;
field.SetWidget(rect, PdfAnnotation.HIGHLIGHT_NONE);
field.Quadding = PdfFormField.Q_RIGHT;
field.SetFieldFlags(PdfFormField.FF_READ_ONLY);
writer.AddAnnotation(field);
}