Remove annotations

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Viewer MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-viewer -- dnx GroupDocs.Viewer.Mcp --yes
Folders, licensing and more →

On this page

If the output PDF file contains annotations, you can remove them to reduce the file size.

To remove annotations, set the RemoveAnnotations property to true.

The following code snippet shows how to remove annotations from the file:

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...

using (var viewer = new Viewer("order_form.pdf"))
{
    PdfViewOptions viewOptions = new PdfViewOptions();
    viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions();
    viewOptions.PdfOptimizationOptions.RemoveAnnotations = true;

    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer = New Viewer("order_form.pdf")
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()
            viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions()
            viewOptions.PdfOptimizationOptions.RemoveAnnotations = True
        
            viewer.View(viewOptions)
        End Using
    End Sub
End Module

order_form.pdf is the sample file used in this example. Click here to download it.

Binary file (PDF, 207 KB)

Download full output

On this page