PdfPig icon indicating copy to clipboard operation
PdfPig copied to clipboard

Question: Is PdfDocument objects and others are thread-save?

Open securigy opened this issue 2 years ago • 1 comments

I mean: if 2 separate threads each call pdfDocument.Open and then process the stream:

  • Is it safe
  • will they share any kind of "state"?
  • will there be 2 different instances of PDF data that each thread will work on?

securigy avatar Dec 25 '23 02:12 securigy

While a PdfDocument instance is not thread safe I think 2 different PdfDocuments should be. There are some shared global caches for things like system fonts, CMap objects and Standard14 fonts I think each of these is thread safe.

Assuming you just call PdfDocument.Open and pass the file path apart from the globally shared data between all PDF files they will operate on separate instances.

EliotJones avatar Jan 07 '24 16:01 EliotJones