3

The new version of Ghostscript (9.07) has a threading support (can be thread-safe), but it says that the code must be compiled with a special flag to enable this.

How do I do this? Or where can I get already built thread-safe version?

I tried to download the source, opened in VS, but it failed to build. So maybe somebody has already done this and could share the DLL.

net_prog
  • 9,921
  • 16
  • 55
  • 70

3 Answers3

2

Are you interested in the thread safe version of Ghostscript, or multiple rendering threads?

Multiple rendering threads are only of use if you are producing high resolution output, since the code must first interpret the PostScript program (or PDF file) and create a display list for the rendering threads to operate on. Unless you are rendering to a reasonably high resolution, this will actually be slower than using page mode (whole page rendered in memory)

You can create multiple rendering threads in the pre-built version of Ghostscript using the -dNumRenderingThreads switch.

If you want a thread-safe version of Ghostscript then you will need to be able to compile Ghostscript yourself. What version of Visual Studio are you using ? I am using Visual Studio 2005 and 2008 and the supplied solution works for me (after appropriate conversion).

KenS
  • 30,202
  • 3
  • 34
  • 51
  • I need a thread-safe compilation for VS 2012, so that I can initialize several instances of Ghostscript from multiple threads at once. I believe the compiled DLL will work from VS 2005/2008, so if you could share it, that would be very helpful, because I have no idea how to properly compile C code with a custom flag. – net_prog Feb 26 '13 at 16:07
  • I don't have a pre-built DLL with the flag set, you'll have to make it yourself. You can get a copy of VS 2010 express which will build the supplied project.To set the flag, simply right-click the solution name in the solution explorer, select 'Properties' from the drop-down menu. Then select C/C++ from the property page, click the little arrow, so the options appear, select 'Preprocessor' and then in the right pane where it says 'Preprocessor definitions' add the THREADSAFE flag. – KenS Feb 27 '13 at 08:09
  • Unfortunately, it failed to build in VS 2010 as well. – net_prog Mar 05 '13 at 02:19
  • Well you can open a bug report at http://bugs.ghostscript.com Please remember to describe the failure, 'fails to build' doesn't help a lot. – KenS Mar 05 '13 at 08:12
1

I was looking for solution for this problem as well and eventually I solved it in Linux. Maybe it will help someone who comes here looking for solution. Open terminal in sources directory and type this command:

./configure --enable-threadsafe

After that you can do make or make so for lib. Here is link to docs for building ghostscript from sources: https://www.ghostscript.com/doc/9.23/Make.htm#Makefile_overview.

Herman
  • 155
  • 4
  • 13
0

Take a look at Ghostscript.NET managed Ghostscript wrapper which allows you to run multiple instances of Ghostscript library at a same time if you have a need to process multiple pdf's at a same time.

HABJAN
  • 9,212
  • 3
  • 35
  • 59