XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to HTML5 Viewer & Editor 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
Sticky note
  |  
Home ›› XDoc.PDF ›› C# PDF: Add Sticky Note

C#.NET PDF SDK - Add Sticky Note to PDF Page in C#.NET


C#.NET Tutorial for How to Add a Sticky Note Annotation to PDF Page with Visual C# Language in .NET Project




A best application for annotation PDF document in Visual C#.NET application and ASP.NET WebForm project


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


Evaluation library and components enable users to annotate PDF without adobe PDF reader control installed


Able to add notes to PDF using C# source code in Visual Studio .NET framework


Allow users to add comments online in ASPX webpage


Able to change font size in PDF comment box


Able to save and print sticky notes in PDF file




C# add sticky note annotation to pdf document


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




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

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

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

annot.Position = new PointF(100F, 100F);

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

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




C# read sticky note annotation from pdf document





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

PDFDocument doc = new PDFDocument(inputFilePath);
List<IPDFAnnot> annots = PDFAnnotHandler.GetAllAnnotations(doc);
foreach (IPDFAnnot annot in annots)
{
    if (annot is PDFAnnotStickyNote)
    {
        PDFAnnotStickyNote obj = (PDFAnnotStickyNote)annot;
        Console.WriteLine("Color: " + obj.Color.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);




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



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;