ByteScout Premium Suite - C# - PDF files Parallel Processing with PDF Extractor SDK - ByteScout

ByteScout Premium Suite – C# – PDF files Parallel Processing with PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – C# – PDF files Parallel Processing with PDF Extractor SDK

PDF files parallel processing with PDF extractor SDK in C# and ByteScout Premium Suite

PDF files parallel processing with PDF extractor SDK in C#

ByteScout tutorials describe the stuff for programmers who use C#. ByteScout Premium Suite was made to help with PDF files parallel processing with PDF extractor SDK in C#. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.

The below SDK samples describe how to quickly make your application do PDF files parallel processing with PDF extractor SDK in C# with the help of ByteScout Premium Suite. Follow the steps-by-step instructions from the scratch to work and copy and paste code for C# into your editor. This basic programming language sample code for C# will do the whole work for you in implementing PDF files parallel processing with PDF extractor SDK in your app.

On our website you may get trial version of ByteScout Premium Suite for free. Source code samples are included to help you with your C# application.

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

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

Program.cs
      
using System; using System.IO; using System.Threading; using Bytescout.PDFExtractor; namespace Parallel_Processing { class Program { // Limit to 4 threads in queue. // Set this value to number of your processor cores for max performance. private static readonly Semaphore ThreadLimiter = new Semaphore(4, 4); static void Main(string[] args) { // Get all PDF files in a folder string[] files = Directory.GetFiles(@"..\..\..\..\", "*.pdf"); // Array of events to wait ManualResetEvent[] doneEvents = new ManualResetEvent[files.Length]; for (int i = 0; i < files.Length; i++) { // Wait for the queue ThreadLimiter.WaitOne(); // Start thread with filename and event in params doneEvents[i] = new ManualResetEvent(false); object[] threadData = new object[] { files[i], doneEvents[i] }; ThreadPool.QueueUserWorkItem(ConvertPdfToTxt, threadData); } // Wait until all threads finish WaitHandle.WaitAll(doneEvents); Console.WriteLine(); Console.WriteLine("All is done."); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } private static void ConvertPdfToTxt(object state) { // Get filename and event from params string file = (string) ((object[]) state)[0]; ManualResetEvent doneEvent = (ManualResetEvent)((object[])state)[1]; string resultFileName = Path.GetFileName(file) + ".txt"; try { Console.WriteLine("Converting " + file); using (TextExtractor extractor = new TextExtractor("demo", "demo")) { extractor.LoadDocumentFromFile(file); extractor.SaveTextToFile(resultFileName); } Console.WriteLine("Finished " + resultFileName); } finally { // Signal the thread is finished doneEvent.Set(); // Release semaphore ThreadLimiter.Release(); } } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

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

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next