All docs
V21.1
21.2 (EAP/Beta)
21.1
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.

How to: Flatten Annotations

  • 2 minutes to read

The following article describes how to use PDF Document Facade to flatten PDF annotations.

Important

The Universal Subscription or an additional Office File API Subscription is required to use this example in production code. Refer to the DevExpress Subscription page for pricing information.

The PdfViewerExtensions.GetDocumentFacade(IPdfViewer) method retrieves the PdfDocumentFacade class object that allows you to change the PDF document without access to its inner structure.

The PdfDocumentFacade allows you to flatten all document annotations, annotations on a specific page, and a single annotation. Utilize one of the following methods to complete the task:

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

The code sample below flattens document annotations:

PdfDocumentFacade documentFacade = pdfViewer.GetDocumentFacade();

// Flatten all text annotations in the document:
documentFacade.FlattenAnnotations(PdfAnnotationType.Text);

PdfPageFacade pageFacade = documentFacade.Pages[0];

SizeF pageSize = pdfViewer.GetPageSize(0);
double halfPage = pageSize.Height / 2; 

// Flatten annotations that are located
// on the lower half of the page:
pageFacade.FlattenAnnotations(x => x.Rectangle.Top < halfPage);

var annotations = documentFacade.Pages[0].Annotations;

// Flatten the first annotation:
annotations[0].Flatten();