ByteScout PDF Extractor SDK - VB.NET - Remove Empty Pages - ByteScout

ByteScout PDF Extractor SDK – VB.NET – Remove Empty Pages

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Extractor SDK – VB.NET – Remove Empty Pages

How to remove empty pages in VB.NET with ByteScout PDF Extractor SDK

This tutorial will show how to remove empty pages in VB.NET

With this source code sample you may quickly learn how to remove empty pages in VB.NET. ByteScout PDF Extractor SDK is the SDK that helps developers to extract data from unstructured documents, pdf, images, scanned and electronic forms. Includes AI functions like automatic table detection, automatic table extraction and restructuring, text recognition and text restoration from pdf and scanned documents. Includes PDF to CSV, PDF to XML, PDF to JSON, PDF to searchable PDF functions as well as methods for low level data extraction. It can be used to remove empty pages using VB.NET.

This rich sample source code in VB.NET for ByteScout PDF Extractor SDK includes the number of functions and options you should do calling the API to remove empty pages. This VB.NET sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Further enhancement of the code will make it more vigorous.

Trial version of ByteScout PDF Extractor SDK is available for free. Source code samples are included to help you with your VB.NET app.

Try ByteScout PDF Extractor SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Module1.vb
      
Imports System.IO Imports Bytescout.PDFExtractor ''' <summary> ''' The example demonstrates detection of empty pages, splitting the document to separate ''' pages excluding empty ones, then combine parts back to a single document. ''' </summary> Module Module1 Dim InputFile = ".\sample.pdf" Dim OutputFile = ".\result.pdf" Dim TempFolder = ".\temp" Sub Main() ' Create and setup Bytescout.PDFExtractor.TextExtractor instance Dim extractor As New TextExtractor("demo", "demo") ' Load PDF document extractor.LoadDocumentFromFile(InputFile) ' List to keep non-empty page numbers Dim nonEmptyPages = New List(Of String)() ' Iterate through pages For pageIndex = 0 To extractor.GetPageCount() - 1 ' Extract page text Dim pageText = extractor.GetTextFromPage(pageIndex) ' If extracted text is not empty keep the page number If pageText.Length > 0 Then nonEmptyPages.Add((pageIndex + 1).ToString()) End If Next ' Cleanup extractor.Dispose() ' Form comma-separated list of page numbers to split ("1,3,5") Dim ranges As String = String.Join(",", nonEmptyPages) ' Create Bytescout.PDFExtractor.DocumentSplitter instance Dim splitter = new DocumentSplitter("demo", "demo") splitter.OptimizeSplittedDocuments = true ' Split document by non-empty in temp folder Dim parts = splitter.Split(InputFile, ranges, TempFolder) ' Cleanup splitter.Dispose() ' Create Bytescout.PDFExtractor.DocumentMerger instance Dim merger = New DocumentMerger("demo", "demo") ' Merge parts merger.Merge(parts, OutputFile) ' Cleanup merger.Dispose() ' Delete temp folder Directory.Delete(TempFolder, true) ' Open the result file in default PDF viewer (for demo purposes) Process.Start(OutputFile) End Sub End Module

Try ByteScout PDF Extractor SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout PDF Extractor SDK Home Page

Explore ByteScout PDF Extractor SDK Documentation

Get ByteScout PDF Extractor SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next