Please give a brief summary of your issue:
FindReplace.FindReplaceText usage in parallel pdf editing
Please describe your issue and provide steps to reproduce it:
I am attempting to run a .NET background worker that finds text and replaces them with different text in a pdf. This worker is attempting to run on 5-10 completely distinct pdfs. If i ever try to run more than one in parallel i get an error of:
”PDFNet is running in demo mode.
PackageV2: base
PackageV2: pdf_text_editing
Fatal error.
0xC0000005
at pdftron.PDFNetPINVOKE.TRN_FindReplaceFindReplaceTextWithOptsObj(IntPtr, IntPtr, IntPtr, IntPtr)”
And an unhandled System.ExecutionEngineException that seems to not be caught by try/catches and completely crashes the worker.
I have included a console app that can be run if you update the inputdir variable with a folder location with multiple pdfs. Add a license and anything above 1 on the concurrency amount causes the error.
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
It seems like you’re facing an issue with running multiple instances of text replacement operations on PDFs in parallel using PDFTron.NET. The error you’re encountering suggests that there might be a problem with how the PDFNet library is being initialized or used in a parallel processing environment.
Some things you can try:
Ensure that PDFNet is initialized only once in your application. The PDFNet.Initialize method should be called once, usually at the start of your application, and not inside parallel threads.
Consider using a lock mechanism or semaphore to control access to shared resources if your code involves shared state or resources.
Ensure that each PDF document is processed independently. Each thread should create its own instance of PDFDoc and perform operations on it.
Check if your license key is correctly applied and that the SDK is not running in demo mode inadvertently.
Use the FindReplace functionality within a try-catch block to catch any exceptions and handle them gracefully.