ByteScout PDF Suite - C# - Convert Scanned PDF to Excel - 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 PDF Suite – C# – Convert Scanned PDF to Excel

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – C# – Convert Scanned PDF to Excel

How to convert scanned PDF to excel in C# using ByteScout PDF Suite

Learn to convert scanned PDF to excel in C#

The sample source code below will teach you how to convert scanned PDF to excel in C#. ByteScout PDF Suite can convert scanned PDF to excel. It can be applied from C#. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.

Want to quickly learn? This fast application programming interfaces of ByteScout PDF Suite for C# plus the guidelines and the code below will help you quickly learn how to convert scanned PDF to excel. IF you want to implement the functionality, just copy and paste this code for C# below into your code editor with your app, compile and run your application. This basic programming language sample code for C# will do the whole work for you to convert scanned PDF to excel.

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

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

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

Form1.Designer.cs
      
namespace Sample_UI_Application { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.pdfViewerControl1 = new Bytescout.PDFViewer.PDFViewerControl(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.tsbOpen = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.tsbExportToCSV = new System.Windows.Forms.ToolStripButton(); this.tsbExportToXLSX = new System.Windows.Forms.ToolStripButton(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // pdfViewerControl1 // this.pdfViewerControl1.BackColor = System.Drawing.SystemColors.ButtonShadow; this.pdfViewerControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.pdfViewerControl1.Location = new System.Drawing.Point(0, 25); this.pdfViewerControl1.MouseMode = Bytescout.PDFViewer.MouseMode.Selection; this.pdfViewerControl1.Name = "pdfViewerControl1"; this.pdfViewerControl1.RegistrationKey = null; this.pdfViewerControl1.RegistrationName = null; this.pdfViewerControl1.ResetRotationOnPageChange = false; this.pdfViewerControl1.Scale = 100; this.pdfViewerControl1.SelectionColor = System.Drawing.Color.Red; this.pdfViewerControl1.ShowImageObjects = true; this.pdfViewerControl1.ShowTextObjects = true; this.pdfViewerControl1.ShowVectorObjects = true; this.pdfViewerControl1.Size = new System.Drawing.Size(842, 514); this.pdfViewerControl1.TabIndex = 0; // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsbOpen, this.toolStripSeparator1, this.tsbExportToCSV, this.tsbExportToXLSX}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(842, 25); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; // // tsbOpen // this.tsbOpen.Image = global::Sample_UI_Application.Properties.Resources.folder_page; this.tsbOpen.ImageTransparentColor = System.Drawing.Color.Magenta; this.tsbOpen.Name = "tsbOpen"; this.tsbOpen.Size = new System.Drawing.Size(80, 22); this.tsbOpen.Text = "&Open PDF"; this.tsbOpen.Click += new System.EventHandler(this.tsbOpen_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // // tsbExportToCSV // this.tsbExportToCSV.Image = ((System.Drawing.Image)(resources.GetObject("tsbExportToCSV.Image"))); this.tsbExportToCSV.ImageTransparentColor = System.Drawing.Color.Magenta; this.tsbExportToCSV.Name = "tsbExportToCSV"; this.tsbExportToCSV.Size = new System.Drawing.Size(100, 22); this.tsbExportToCSV.Text = "Export To CSV"; this.tsbExportToCSV.Click += new System.EventHandler(this.tsbExportToCSV_Click); // // tsbExportToXLSX // this.tsbExportToXLSX.Image = ((System.Drawing.Image)(resources.GetObject("tsbExportToXLSX.Image"))); this.tsbExportToXLSX.ImageTransparentColor = System.Drawing.Color.Magenta; this.tsbExportToXLSX.Name = "tsbExportToXLSX"; this.tsbExportToXLSX.Size = new System.Drawing.Size(105, 22); this.tsbExportToXLSX.Text = "Export To XLSX"; this.tsbExportToXLSX.Click += new System.EventHandler(this.tsbExportToXLSX_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(842, 539); this.Controls.Add(this.pdfViewerControl1); this.Controls.Add(this.toolStrip1); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private Bytescout.PDFViewer.PDFViewerControl pdfViewerControl1; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton tsbOpen; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton tsbExportToCSV; private System.Windows.Forms.ToolStripButton tsbExportToXLSX; } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Form1.cs
      
using System; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; using Bytescout.PDFExtractor; namespace Sample_UI_Application { // This example requires 'PDF Viewer SDK' and 'PDF Extractor SDK' installed. // Download link: http://cdn.bytescout.com/ByteScoutInstaller.exe public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { // Preload document into viewer pdfViewerControl1.InputFile = @".\sample_ocr.pdf"; base.OnLoad(e); } private void tsbOpen_Click(object sender, EventArgs e) { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Title = @"Open PDF Document"; openFileDialog.Filter = @"PDF Files (*.pdf)|*.pdf|All Files|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) { this.Text = openFileDialog.FileName; Cursor = Cursors.WaitCursor; try { pdfViewerControl1.InputFile = openFileDialog.FileName; } catch (Exception exception) { MessageBox.Show(exception.Message); } finally { Cursor = Cursors.Default; } } } } private void tsbExportToCSV_Click(object sender, EventArgs e) { // Get selections from viewer RectangleF[] selections = pdfViewerControl1.SelectionInPoints; string outputFile = @".\result.csv"; using (CSVExtractor csvExtractor = new CSVExtractor("demo", "demo")) { // Load document into extractor csvExtractor.LoadDocumentFromFile(pdfViewerControl1.InputFile); // Enable OCR to recongize text from images csvExtractor.OCRMode = OCRMode.Auto; csvExtractor.OCRResolution = 300; csvExtractor.OCRLanguage = "eng"; csvExtractor.OCRLanguageDataFolder = @"c:\Program Files\Bytescout PDF Extractor SDK\net4.00\tessdata\"; // There are double spaces between some words in your document. // To avoid such words break column structure increase the space ratio to 2. csvExtractor.DetectNewColumnBySpacesRatio = 2; // FYI, removing horizontal lines may increase the text recognition quality in some cases csvExtractor.OCRImagePreprocessingFilters.AddHorizontalLinesRemover(); // Another filter able to improve the recognition //csvExtractor.OCRImagePreprocessingFilters.AddGammaCorrection(); // If selection exists set the extraction area. // Overwise it will extract the whole page. if (selections.Length > 0) csvExtractor.SetExtractionArea(selections[0]); // Save extraction results to CSV files csvExtractor.SavePageCSVToFile(pdfViewerControl1.CurrentPageIndex, outputFile); } Process.Start(outputFile); } private void tsbExportToXLSX_Click(object sender, EventArgs e) { // Get selections from viewer RectangleF[] selections = pdfViewerControl1.SelectionInPoints; string outputFile = @".\result.xlsx"; using (XLSExtractor xlsExtractor = new XLSExtractor("demo", "demo")) { // Load document into extractor xlsExtractor.LoadDocumentFromFile(pdfViewerControl1.InputFile); xlsExtractor.OCRMode = OCRMode.Auto; xlsExtractor.OCRResolution = 300; xlsExtractor.OCRLanguage = "eng"; xlsExtractor.OCRLanguageDataFolder = @"c:\Program Files\Bytescout PDF Extractor SDK\net4.00\tessdata\"; xlsExtractor.OutputFormat = SpreadseetOutputFormat.XLSX; xlsExtractor.RichTextFormatting = false; // There are double spaces between some words in your document. // To avoid such words break column structure increase the space ratio to 2. xlsExtractor.DetectNewColumnBySpacesRatio = 2; // FYI, removing horizontal lines may increase the text recognition quality in some cases //xlsExtractor.OCRImagePreprocessingFilters.AddHorizontalLinesRemover(); // Another filter able to improve the recognition //xlsExtractor.OCRImagePreprocessingFilters.AddGammaCorrection(); // If selection exists set the extraction area. // Overwise it will extract the whole page. if (selections.Length > 0) xlsExtractor.SetExtractionArea(selections[0]); // Save extraction results to XLSX files xlsExtractor.SavePageToXLSFile(pdfViewerControl1.CurrentPageIndex, outputFile); } Process.Start(outputFile); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Program.cs
      
using System; using System.Collections.Generic; using System.Windows.Forms; namespace Sample_UI_Application { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

app.config
      
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF 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 PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next