An easy to understand guide to learn how to parallel processing of pdf files with pdf extractor sdk in VB.NET. ByteScout PDF Suite helps with parallel processing of pdf files with pdf extractor sdk in VB.NET. 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.
The below SDK samples describe how to quickly make your application do parallel processing of pdf files with pdf extractor sdk in VB.NET with the help of ByteScout PDF Suite. Just copy and paste this VB.NET sample code to your VB.NET application’s code editor, add a reference to ByteScout PDF Suite (if you haven’t added yet) and you are ready to go! Further improvement of the code will make it more robust.
ByteScout PDF Suite is available as a free trial. You may get it from our website along with all other source code samples for VB.NET applications.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Imports System.IO
Imports System.Threading
Imports Bytescout.PDFExtractor
Module Module1
' Limit to 4 threads in queue.
' Set this value to number of your processor cores for max performance.
ReadOnly ThreadLimiter As Semaphore = New Semaphore(4, 4)
<MTAThread()>
Sub Main()
' Get all PDF files in a folder
Dim files = Directory.GetFiles("..\..\..\..\", "*.pdf")
' Array of events to wait
Dim doneEvents(files.Length - 1) As ManualResetEvent
For i As Integer = 0 To files.Length - 1
' Wait for the queue
ThreadLimiter.WaitOne()
' Start thread with filename and event in params
doneEvents(i) = New ManualResetEvent(False)
Dim threadData As Object = New Object() {files(i), doneEvents(i)}
ThreadPool.QueueUserWorkItem(AddressOf ConvertPdfToTxt, threadData)
Next
' 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()
End Sub
Private Sub ConvertPdfToTxt(ByVal state As Object)
' Get filename and event from params
Dim file As String = state(0)
Dim doneEvent As ManualResetEvent = state(1)
Dim resultFileName = Path.GetFileName(file) + ".txt"
Try
Console.WriteLine("Converting " + file)
Using extractor As New TextExtractor("demo", "demo")
extractor.LoadDocumentFromFile(file)
extractor.SaveTextToFile(resultFileName)
End Using
Console.WriteLine("Finished " + resultFileName)
Finally
' Signal the thread is finished
doneEvent.Set()
' Release semaphore
ThreadLimiter.Release()
End Try
End Sub
End Module
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: