ByteScout Barcode Reader SDK – ASP.NET C# – Decode page by page from PDF OR TIFF

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Reader SDK – ASP.NET C# – Decode page by page from PDF OR TIFF

How to decode page by page from PDF OR TIFF in ASP.NET C# using ByteScout BarCode Reader SDK

Write code in ASP.NET C# to decode page by page from PDF OR TIFF with this step-by-step tutorial

This sample source code below will demonstrate you how to decode page by page from PDF OR TIFF in ASP.NET C#. ByteScout BarCode Reader SDK is the SDK for reading of barcodes from PDF, images and live camera or video. Almost every common type like Code 39, Code 128, GS1, UPC, QR Code, Datamatrix, PDF417 and many others are supported. Supports noisy and defective images and docs. Includes optional documents splitter and merger for pdf and tiff based on found barcodess. Batch mode is supported for superior performance using multiple threads. Decoded values are easily exported to JSON, CSV, XML and to custom format and you can use it to decode page by page from PDF OR TIFF with ASP.NET C#.

This rich sample source code in ASP.NET C# for ByteScout BarCode Reader SDK includes the number of functions and options you should do calling the API to decode page by page from PDF OR TIFF. Follow the instructions from the scratch to work and copy the ASP.NET C# code. Test ASP.NET C# sample code examples whether they respond your needs and requirements for the project.

Our website provides trial version of ByteScout BarCode Reader SDK for free. It also includes documentation and source code samples.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebTestSharp._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Web Barcode Reader Tester (C#)</title>
    <form id="form1" runat="server">
            Click browse button to upload a PDF/TIFF document<br />
            <asp:FileUpload ID="FileUpload1" runat="server" /><br />
            <br />
            Page No. to read barcode from:
        <asp:TextBox ID="txtPageNo" Text="1" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="UploadButton"
                Text="Upload file and read barcodes"
            <br />
            <asp:Label ID="UploadStatusLabel" Text="" runat="server"></asp:Label>
            <br />
            <asp:ListBox ID="ListBox1" runat="server" Visible="False"></asp:ListBox><br />
            <br />

using System;
using Bytescout.BarCodeReader;

namespace WebTestSharp
	public partial class _Default : System.Web.UI.Page
		protected void UploadButton_Click(object sender, EventArgs e)
			String savePath = @"\uploads\";

			if (FileUpload1.HasFile)
				String fileName = FileUpload1.FileName;
				savePath += fileName;

				Reader barcodeReader = new Reader();

				// Limit search to 1D barcodes only (exclude 2D barcodes to speed up the search).
				// Change to barcodeReader.BarcodeTypesToFind.SetAll() to scan for all supported 1D and 2D barcodes 
				// or select specific type, e.g. barcodeReader.BarcodeTypesToFind.PDF417 = True

				// reader.MediumTrustLevelCompatible = true; // uncomment this line to enable Medium Trust compatible mode (slows down the recognition process as direct image data access is disabled in Medium Trust mode)
				UploadStatusLabel.Visible = false;

                // Page No to read
                int PageNoToRead = Convert.ToInt32(txtPageNo.Text);

				ListBox1.Visible = true;
				ListBox1.Items.Add("Reading barcode(s) from file \"" + fileName + "\"" + ", Page No: " + PageNoToRead);

                // Reading barcode from document on page-by-page basic
				FoundBarcode[] barcodes = barcodeReader.ReadFrom(Server.MapPath(savePath), (PageNoToRead - 1));

				if (barcodes.Length == 0)
					ListBox1.Items.Add("No barcodes found");
					foreach (FoundBarcode barcode in barcodes)
                        ListBox1.Items.Add(String.Format("Found barcode - Type: '{0}', Value: '{1}', Position: '{2}'", barcode.Type, barcode.Value, barcode.Rect.ToString()));
				// Notify the user that a file was not uploaded.
				UploadStatusLabel.Text = "You did not specify a file to upload.";