Writing of the code to parallel processing of pdf files with pdf extractor sdk in VB.NET can be done by developers of any level using ByteScout Premium Suite. ByteScout Premium Suite was made to help with parallel processing of pdf files with pdf extractor sdk in VB.NET. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.
Save time on writing and testing code by using the code below and use it in your application. If you want to know how it works, then this VB.NET sample code should be copied and pasted into your application’s code editor. Then just compile and run it. Further improvement of the code will make it more robust.
On our website you may get trial version of ByteScout Premium Suite for free. Source code samples are included to help you with your VB.NET application.
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 Premium Suite Home Page
Explore ByteScout Premium Suite Documentation
Explore Samples
Sign Up for ByteScout Premium Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
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
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: