How to delete blank pages from an existing PDF document?
The Syncfusion Essential® PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can delete blank pages from an existing PDF document.
Steps to delete blank pages from an existing PDF document
- Create a new Windows Forms application project.

- Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from nuget.org.

- Include the following namespaces in the Form1.cs file.
C#
using Syncfusion.Pdf; using Syncfusion.Pdf.Parsing; using System.Drawing;
VB.NET
Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Parsing Imports System.Drawing
- Add the following code in button1_Click to delete blank pages from an existing PDF document.
C#
//Load PDF document
PdfLoadedDocument lDoc = new PdfLoadedDocument("../../Data/Blank.pdf");
//Disable the incremental update
lDoc.FileStructure.IncrementalUpdate = false;
//Set the cross reference type
lDoc.FileStructure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceStream;
int i = 0;
while (i < lDoc.Pages.Count)
{
//Extract image from the loaded page
Image[] img = lDoc.Pages[i].ExtractImages();
//Extract text from the existing page
string text = lDoc.Pages[i].ExtractText();
//If extracted images and string are empty, then remove the blank page
if (img.Length == 0 && string.IsNullOrEmpty(text))
lDoc.Pages.RemoveAt(i);
i += 1;
}
//Save the PDF document
lDoc.Save("Output.pdf");
//Closes the document
lDoc.Close(true);
//This will open the PDF file and the result will be seen in the default PDF Viewer
Process.Start("Output.pdf");
VB.NET
'Load PDF document
Dim lDoc As New PdfLoadedDocument("../../Data/Blank.pdf")
'Disable the incremental update
lDoc.FileStructure.IncrementalUpdate = False
'Set the cross reference type
lDoc.FileStructure.CrossReferenceType = PdfCrossReferenceType.CrossReferenceStream
Dim i As Integer = 0
Do While i < lDoc.Pages.Count
'Extract image from the loaded page
Dim img() As Image = lDoc.Pages(i).ExtractImages()
'Extract text from the existing page
Dim text As String = lDoc.Pages(i).ExtractText()
'If extracted images and string are empty, then remove the blank page
If img.Length = 0 AndAlso String.IsNullOrEmpty(text) Then
lDoc.Pages.RemoveAt(i)
End If
i += 1
Loop
'Save the PDF document
lDoc.Save("Sample.pdf")
'Close the document
lDoc.Close(True)
'This will open the PDF file and the result will be seen in the default PDF Viewer
Process.Start("Output.pdf")
A complete working sample can be downloaded from DeleteBlankPage.zip.
Take a moment to peruse the documentation. You can find more about Text extraction and Image extraction. Also, find the other options like drawing right-to-left text, multi-column text, consuming TrueType fonts, standard fonts, CJK fonts, and more.
See Also:
Extract text from PDF document
Extract images from PDF document
Conclusion:
I hope you enjoyed learning about how to delete blank pages from an existing PDF document.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!