Skip to main content
All docs
V25.1
  • PdfLineAnnotationFacade Class

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

    Namespace: DevExpress.Pdf

    Assembly: DevExpress.Pdf.v25.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public class PdfLineAnnotationFacade :
        PdfPathAnnotationFacade

    The following members return PdfLineAnnotationFacade objects:

    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