On this page you will learn from code samples for programming in C#. ByteScout PDF Extractor SDK was made to help with PDF files parallel processing in C#. ByteScout PDF Extractor SDK is the SDK that helps developers to extract data from unstructured documents, pdf, images, scanned and electronic forms. Includes AI functions like automatic table detection, automatic table extraction and restructuring, text recognition and text restoration from pdf and scanned documents. Includes PDF to CSV, PDF to XML, PDF to JSON, PDF to searchable PDF functions as well as methods for low level data extraction.
You will save a lot of time on writing and testing code as you may just take the code below and use it in your application. In order to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. This basic programming language sample code for C# will do the whole work for you in implementing PDF files parallel processing in your app.
ByteScout PDF Extractor SDK is available as 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)
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(); } } } }
60 Day Free Trial or Visit ByteScout PDF Extractor SDK Home Page
Explore ByteScout PDF Extractor SDK Documentation
Explore Samples
Sign Up for ByteScout PDF Extractor SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout PDF Extractor SDK Home Page
Explore ByteScout PDF Extractor SDK Documentation
Explore Samples
Sign Up for ByteScout PDF Extractor SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: