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

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

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

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

Learn PDF files parallel processing with PDF extractor SDK in C#

We regularly create and update our sample code library so you may quickly learn PDF files parallel processing with PDF extractor SDK and the step-by-step process in C#. PDF files parallel processing with PDF extractor SDK in C# can be applied with ByteScout PDF Suite. ByteScout PDF Suite is the set that includes 6 SDK products 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 speed up the application development? Then this C#, code samples for C#, developers help to speed up the application development and writing a code when using ByteScout PDF Suite. Just copy and paste this C# sample code to your C# application’s code editor, add a reference to ByteScout PDF Suite (if you haven’t added yet) and you are ready to go! 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.

ByteScout PDF Suite is available as a free trial. You may get it from our website along with all other source code samples for C# applications.

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 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