XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Text other markups
  |  
Home ›› XDoc.PDF ›› C# PDF: Drawing Markups

C#.NET PDF SDK - Draw Markup on PDF Page in C#.NET


Various C# Demo Codes to Draw Markup on PDF Page Using .NET PDF Library in C# Program




A best PDF annotator control for Visual Studio .NET support to markup PDF with various annotations in C#.NET class


A web based markup tool able to annotate PDF in browser such as chrome, firefox and safari in ASP.NET WebForm application


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Free .NET library and components to draw on PDF file in C#.NET WinForms program


Free online C# source code to draw markup on adobe PDF file in C#.NET framework


Able to markup PDF and scale PDF drawing in .NET without other plug-ins


Able to add stamps to PDF document in C#.NET


Able to remove or crop marks from PDF document


Support to draw freehand annotations, trikethrough text, underline text, insert and replace text


Since RasterEdge XDoc.PDF SDK is based on .NET framework 2.0, users are enabled to use it in any type of a 32-bit or 64-bit .NET application, including ASP.NET web service and Windows Forms for any .NET Framework version from 2.0 to 4.5.





C# add insert text at cursor annotation to pdf document





String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_4.pdf";

//  open a PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 2nd page
PDFPage page = (PDFPage)doc.GetPage(1);

//  create the annotation
PDFAnnotTextInsert annot = new PDFAnnotTextInsert();

annot.Position = new PointF(300F, 500F);

//  add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot);

//  save to a new file
doc.Save(outputFilePath);




C# add note to replace text annotation to pdf document





String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_5.pdf";

//  open a PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 2nd page
PDFPage page = (PDFPage)doc.GetPage(1);

//  create the annotation
PDFAnnotTextReplace annot = new PDFAnnotTextReplace();

annot.StartPoint = new PointF(100F, 200F);
annot.EndPoint = new PointF(300F, 400F);

//  add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot);

//  save to a new file
doc.Save(outputFilePath);




C# add strikethrough annotation to pdf document





String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_1.pdf";

//  open a PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 2nd page
PDFPage page = (PDFPage)doc.GetPage(1);

//  create the annotation
PDFAnnotDeleteLine annot = new PDFAnnotDeleteLine();

annot.StartPoint = new PointF(100F, 200F);
annot.EndPoint = new PointF(300F, 400F);

//  add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot);

//  save to a new file
doc.Save(outputFilePath);




C# add underline annotation to pdf document





String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_2.pdf";

//  open a PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
//  get the 2nd page
PDFPage page = (PDFPage)doc.GetPage(1);

//  create the annotation
PDFAnnotUnderLine annot = new PDFAnnotUnderLine();

annot.StartPoint = new PointF(100F, 200F);
annot.EndPoint = new PointF(300F, 400F);

//  add annotation to the page
PDFAnnotHandler.AddAnnotation(page, annot);

//  save to a new file
doc.Save(outputFilePath);




C# retrieve annotation popup note window��s properties





String inputFilePath = Program.RootPath + "\\" + "Annot_1.pdf";

PDFDocument doc = new PDFDocument(inputFilePath);
List<IPDFAnnot> annots = PDFAnnotHandler.GetAllAnnotations(doc);
foreach (IPDFAnnot annot in annots)
{
    if (annot is IPDFPopupAnnot)
    {
        Console.WriteLine("Annotation has popup window");

        IPDFPopupAnnot obj = (IPDFPopupAnnot)annot;
        Console.WriteLine("Is open in the begin:  " + obj.Popup.IsOpen);
        Console.WriteLine("Popup window boundary: " + obj.Popup.Boundary.ToString());
    }
    else
    {
        Console.WriteLine("Annotation has no popup window");
    }
}




C# retrieve annotation flags





String inputFilePath = Program.RootPath + "\\" + "Annot_1.pdf";

PDFDocument doc = new PDFDocument(inputFilePath);
List<IPDFAnnot> annots = PDFAnnotHandler.GetAllAnnotations(doc);
foreach (IPDFAnnot annot in annots)
{
    Console.WriteLine("Annotation Flags");
    Console.WriteLine("  Invisible:       " + annot.IsInvisible);
    Console.WriteLine("  Hidden:          " + annot.IsHidden);
    Console.WriteLine("  Print:           " + annot.IsPrint);
    Console.WriteLine("  No Zoom:         " + annot.NoZoom);
    Console.WriteLine("  No Rotate:       " + annot.NoRotate);
    Console.WriteLine("  No View:         " + annot.NoView);
    Console.WriteLine("  Read Only:       " + annot.IsReadOnly);
    Console.WriteLine("  Locked:          " + annot.IsLocked);
    Console.WriteLine("  Toggle No View:  " + annot.IsToggleNoView);
    Console.WriteLine("  Locked Contents: " + annot.IsLockedContents);
}




C# set annotation flags





String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Annot_1.pdf";

//  create the annotation
PDFAnnotDeleteLine annot = new PDFAnnotDeleteLine();
annot.StartPoint = new PointF(100F, 200F);
annot.EndPoint = new PointF(300F, 400F);

//  set annotation flags
annot.IsInvisible = false;
annot.IsPrint = true;
annot.NoRotate = true;
annot.NoZoom = true;

//  add annotation
PDFAnnotHandler.AddAnnotation(inputFilePath, 1, annot, outputFilePath);




.NET Class Namespace Required



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;