ByteScout Barcode Suite - VB.NET - Split pdf document by found barcode with barcode reader sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Barcode Suite – VB.NET – Split pdf document by found barcode with barcode reader sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Suite – VB.NET – Split pdf document by found barcode with barcode reader sdk

How to split pdf document by found barcode with barcode reader sdk in VB.NET with ByteScout Barcode Suite

Learn to code in VB.NET to split pdf document by found barcode with barcode reader sdk with this step-by-step tutorial

The sample shows instructions and algorithm of how to split pdf document by found barcode with barcode reader sdk and how to make it run in your VB.NET application. ByteScout Barcode Suite can split pdf document by found barcode with barcode reader sdk. It can be applied from VB.NET. ByteScout Barcode Suite is the set that includes three different SDK products to generate barcodes, read barcodes and read and write spreadsheets: Barcode SDK, Barcode Reader SDK and Spreadsheet SDK.

The following code snippet for ByteScout Barcode Suite works best when you need to quickly split pdf document by found barcode with barcode reader sdk in your VB.NET application. Follow the instructions from scratch to work and copy the VB.NET code. Enjoy writing a code with ready-to-use sample VB.NET codes.

If you want to try other source code samples then the free trial version of ByteScout Barcode Suite is available for download from our website. Just try other source code samples for VB.NET.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Module1.vb
      
Imports System.IO Imports System.Text Imports Bytescout.BarCodeReader Module Module1 Sub Main() Const inputFile As String = "Barcodes.pdf" Console.WriteLine("Reading barcode(s) from image {0}", Path.GetFullPath(inputFile)) ' Create Bytescout.BarCodeReader.Reader instance Dim reader As New Reader() reader.RegistrationName = "demo" reader.RegistrationKey = "demo" ' Set barcode type to find reader.BarcodeTypesToFind.Code39 = True ' ----------------------------------------------------------------------- ' NOTE: We can read barcodes from specific page to increase performance . ' For sample please refer to "Decoding barcodes from PDF by pages" program. ' ----------------------------------------------------------------------- ' Find barcode in PDF document reader.ReadFrom(inputFile) ' Method 1: Split PDF document in two parts by found barcode ' NOTE: In Full version of the SDK this method is unlocked in "PRO" license type only reader.SplitDocument("barcodes.pdf", "part1.pdf", "part2.pdf", reader.FoundBarcodes(0).Page + 1) ' Method 2: Extract page containing the barcode from PDF document ' NOTE: In Full version of the SDK this method is unlocked in "PRO" license type only reader.ExtractPageFromDocument("barcodes.pdf", "extracted_page.pdf", reader.FoundBarcodes(0).Page + 1) ' Method 3: Split PDF document into parts in one pass. ' NOTE: In Full version of the SDK this method is unlocked in "PRO" license type only. Dim pageRanges As StringBuilder = New StringBuilder() ' Create string containing page ranges to extract in the form "1-4,6-8,10-11,12-". Page numbers are 1-based! For i As Integer = 0 To reader.FoundBarcodes.Length - 1 Dim barcode As FoundBarcode = reader.FoundBarcodes(i) ' Add pages before the first barcode found If i = 0 And barcode.Page > 0 Then pageRanges.Append("1") If barcode.Page > 1 Then pageRanges.Append("-") pageRanges.Append(barcode.Page) End If pageRanges.Append(",") End If ' Add page with barcode pageRanges.Append(barcode.Page + 1) ' +1 because we skip the page with barcode and another +1 because need 1-based page numbers ' Add range untill the next barcode If i < reader.FoundBarcodes.Length - 1 Then If reader.FoundBarcodes(i + 1).Page - barcode.Page > 1 Then pageRanges.Append("-") pageRanges.Append(reader.FoundBarcodes(i + 1).Page) End If pageRanges.Append(",") Else ' for the last found barcode add ending "-" meaning "to the last page" pageRanges.Append("-") End If Next ' Split document Dim splittedParts As String() = reader.SplitDocument("barcodes.pdf", pageRanges.ToString()) ' The method returns array of file names. Rename files as desired. ' Cleanup reader.Dispose() For Each fileName As String In splittedParts Console.WriteLine(fileName) Next Console.WriteLine("Press enter key to exit...") Console.ReadLine() End Sub End Module

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next