|
C# PDF Editor SDK Library
How to add, edit, retrieve, delete PDF file text callout annotations using C#.NET
Sample Codes for C#.NET Users to edit text callout on PDF in C#.NET Class.
ASP.NET Annotate PDF function is based on C# PDF Annotate SDK.
C# add text callout annotation to pdf document
String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_10.pdf";
// open a PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
// get the 1st page
PDFPage page = (PDFPage)doc.GetPage(0);
// create the annotation
PDFAnnotTextCallout annot = new PDFAnnotTextCallout();
annot.StartPoint = new PointF(100F, 100F);
annot.Boundary = new RectangleF(400F, 500F, 300F, 80F);
annot.Content = @"This is a text callout annotation";
// add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot);
// save to a new file
doc.Save(outputFilePath);
C# read text callout annotation from pdf document
String inputFilePath = Program.RootPath + "\\" + "Annot_10.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);
List<IPDFAnnot> annots = PDFAnnotHandler.GetAllAnnotations(doc);
foreach (IPDFAnnot annot in annots)
{
if (annot is PDFAnnotTextCallout)
{
PDFAnnotTextCallout obj = (PDFAnnotTextCallout)annot;
Console.WriteLine("Textbox Boundary: " + obj.GetTextBoxBoundary().ToString());
Console.WriteLine("Textbox Border Color: " + obj.LineColor.ToString());
Console.WriteLine("Textbox Border Width: " + obj.LineWidth);
Console.WriteLine("Textbox Fill Color: " + obj.FillColor.ToString());
Console.WriteLine("Callout Line: ");
foreach (PointF pt in obj.GetEndPoints())
{
Console.WriteLine(" " + pt.ToString());
}
}
}
C# delete all annotations from pdf document
String inputFilePath = Program.RootPath + "\\" + "1_Annots.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);
// get all annotations in the 1st page
PDFPage page = (PDFPage)doc.GetPage(0);
List<IPDFAnnot> annots = PDFAnnotHandler.GetAllAnnotations(page);
// remove all annotations in the 1st page
PDFAnnotHandler.DeleteAnnotation(doc, annots);
|