pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roberto Nibali <rnib...@gmail.com>
Subject Re: PDFont - thread save?
Date Thu, 08 Oct 2015 11:35:42 GMT
Hi

Short answer: from the pdfbox FAQ entry (
https://pdfbox.apache.org/1.8/faq.html#threadsafe) point of view: no,
generally you cannot assume thread-safety with the pdfbox library.

However, it is my personal experience that you can easily parallelize
certain tasks calling pdfbox library methods using a miminal amount of care
and design in the way you invoke and synchronize the threads.

With regard to your issue, I'm afraid that you would need to provide more
information:

   - What is the exact error message you get?
   - How exactly is your libertine_R variable defined? E.g.: a global
   static final PDFont?
   - How do you use your libertine_R variable inside the threads?
   - Could you share some more of your code, especially the part of the
   worker threads?
   - Which framework do you use for your multi-threaded approach?


Best regards
Roberto




On Thu, Oct 8, 2015 at 11:59 AM, M. Niedermair <m_g_n@gmx.de> wrote:

> Hello there,
>
> I load the font "Linux Libertine" in a factory as a singleton (I create
> several hundred PDFs with this font.).
>
> libertine_R = PDTrueTypeFont.loadTTF(document,
>    FontLibertine.class.getResourceAsStream("ttf/LinLibertine_Rah.ttf"));
>
> In single-threaded, this also works without problems.
> But if I start multiple threads that use the Font singelton, there is an
> error. I run four threads per core (4x8 = 32).
>
> As a stopgap, I load the font in each thread individually.
> Is there a better solution?
>
> Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message