All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfLineAnnotationFacade Class

Contains members used to manage line annotations without access to their inner structure.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.2.Core.dll

Declaration

public class PdfLineAnnotationFacade :
    PdfPathAnnotationFacade

Remarks

Create Line Annotations

The code sample below creates a red line annotation:

line annotation

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Define an annotation's start and end points
    PdfPoint start = new PdfPoint(100, 100);
    PdfPoint end = new PdfPoint(150, 100);

    // Add a line annotation
    PdfLineAnnotationFacade lineAnnotation = pageFacade.AddLineAnnotation(start, end);

    // Specify the annotation parameters
    lineAnnotation.Author = "Brian Zetc";
    lineAnnotation.BorderStyle = PdfBorderStyle.DashDot;
    lineAnnotation.BorderWidth = 3;
    lineAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
    lineAnnotation.Contents = "Made in PDF Document API";

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}

Edit Line Annotations

The PdfPageFacade.Annotations property returns all page annotation properties. You can filter line annotation properties, cast them to the PdfLineAnnotationFacade class, and use class properties to modify annotation parameters.

The code sample below retrieves all line annotations on the first page and changes their end style and interior color used to fill the annotation’s line endings:

using DevExpress.Pdf;
using System.Linq;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Retrieve all line annotations
    var lineAnnotations = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Line);
    foreach (PdfLineAnnotationFacade lineAnnotation in lineAnnotations) 
    {
        // Change each line's interior color and ending style
        lineAnnotation.InteriorColor = new PdfRGBColor(0.8, 0.2, 0.1);
        lineAnnotation.LineStartStyle = PdfAnnotationLineEndingStyle.Diamond;
        lineAnnotation.LineEndStyle = PdfAnnotationLineEndingStyle.ClosedArrow;
    }

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}

Flatten Line Annotations

Call one of the following methods to flatten an annotation:

Method Description
PdfDocumentFacade.FlattenAnnotations Flattens document annotations.
PdfPageFacade.FlattenAnnotations Flattens annotations of a specific page.
PdfAnnotationFacade.Flatten() Flattens a specific annotation.

The code sample below flattens all line annotations on the first page:

using DevExpress.Pdf;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Flatten all line annotations
    pageFacade.FlattenAnnotations(PdfAnnotationType.Line);

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}

Remove Line Annotations

Call the PdfAnnotationFacade.Remove() method to remove an annotation. The code sample below removes all line annotations on the first page:

using DevExpress.Pdf;
using System.Linq;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Retrieve all line annotations
    var lineAnnotations = pageFacade.Annotations.Where
      (annotation => annotation.Type == PdfAnnotationType.Line).ToList();
    foreach (PdfLineAnnotationFacade lineAnnotation in lineAnnotations) 
    {
        // Remove all annotations
        lineAnnotation.Remove();
    }

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
See Also