Overview
This article explains how to delete pages from a PDF document using the Remove PDF Pages plugin (RemovePagesPdf) from the GroupDocs.Merger.LowCode package for .NET. GroupDocs Document Merger Plugins are lightweight, single-purpose tools that make merging and splitting documents simple and efficient for .NET developers.
About Document Merger Plugins
GroupDocs Document Merger Plugins are built on our enterprise-grade GroupDocs.Merger SDK. These plugins merge, split, and remove pages in PDF, Word (DOCX), and PowerPoint (PPTX) documents, and are designed for cross-platform use on Windows, macOS, and Linux under .NET 6+. Each plugin offers a lightweight, fixed-price solution for one operation on one format (e.g., Merge PDF), making them ideal for developers who need a simple, focused tool.
Prerequisites
- .NET 6.0 or later
- A license file (
GroupDocs.Merger.LowCode.lic). Without a license, the plugin runs in evaluation mode. - A PDF file to remove pages from
Installation
To install the GroupDocs.Merger.LowCode package, run the following command in your terminal:
dotnet add package GroupDocs.Merger.LowCode
Code Example
The following example removes pages 2 and 4 from source.pdf and saves the remaining pages to output/trimmed.pdf:
using GroupDocs.Merger.Domain.Options;
using GroupDocs.Merger.LowCode;
// Set your license
License.Set("GroupDocs.Merger.LowCode.lic");
// Select pages 2 and 4 to remove
var remover = new RemovePagesPdf("source.pdf", new RemoveOptions(new[] { 2, 4 }));
// Save the remaining pages
remover.Save("output/trimmed.pdf");
VB.NET Example
Imports GroupDocs.Merger.Domain.Options
Imports GroupDocs.Merger.LowCode
' Set your license
License.Set("GroupDocs.Merger.LowCode.lic")
' Select pages 2 and 4 to remove
Dim remover As New RemovePagesPdf("source.pdf", New RemoveOptions({2, 4}))
' Save the remaining pages
remover.Save("output/trimmed.pdf")
F# Example
open GroupDocs.Merger.Domain.Options
open GroupDocs.Merger.LowCode
// Set your license
License.Set("GroupDocs.Merger.LowCode.lic")
// Select pages 2 and 4 to remove
let remover = RemovePagesPdf("source.pdf", RemoveOptions([| 2; 4 |]))
// Save the remaining pages
remover.Save("output/trimmed.pdf")
Output
The document output/trimmed.pdf contains every page of source.pdf except pages 2 and 4. The output folder is created if it doesn’t exist, and an existing file with the same name is overwritten. A page number that is out of range throws a GroupDocsMergerException.
Remove a Range of Pages
Pass the first and the last page of a range to remove all of its pages. Add a RangeMode to remove only the odd or even pages of the range:
using GroupDocs.Merger.Domain.Options;
using GroupDocs.Merger.LowCode;
// Remove pages 5 to 8
var remover = new RemovePagesPdf("source.pdf", new RemoveOptions(5, 8));
// Save the remaining pages
remover.Save("output/without-5-8.pdf");
// Remove the even pages from 1 to 6
var evenRemover = new RemovePagesPdf("source.pdf", new RemoveOptions(1, 6, RangeMode.EvenPages));
// Save the remaining pages
evenRemover.Save("output/without-even-pages.pdf");
The source document can also be a Stream. For more examples in C#, VB.NET, and F#, see Using RemovePagesPdf to Remove Pages from PDF Documents in the documentation.
Licensing
A license is required to use the plugin without evaluation limitations. In evaluation mode, only the first three pages are processed, and an evaluation message is added to every page of the output. Each plugin is licensed separately. You can obtain a free temporary license for testing: