VASmalltalk – Example wrapper for Ghostscript-dll

Someone asked in the Instantiation support forum how to wrap the ghostscript dll. I took a look at that library, did some work and published a small wrapper around that dll – just to produce a pdf document. Actually I do not like Ghostscript, because the license is so restrictive, that nobody seems to be able to use that library in any non-gpl software – and the commercial licenses are …

Please be aware of the GPL/commercial license questions. Though I published my wrapper under the MIT license, it does not mean, that the usage of GHostscript is free. This license is only available for the part of this wrapper. If your program is using Ghostscript as part – either your software should be published under GPL license or you have to buy the commercial license for Ghostscript (which is very expensive !).

Load the configuration map “MSKGhostscriptInterface” and execute the following example code. Please change the path strings according to your situation and make sure, that VA can find the dll (that means: change your PATH settings).

| anInstance anArray |
			
anArray := Array new: 10.
anArray
  at: 1 put: 'ps2pdf' ;
  at: 2 put: '-dNOPAUSE' ;
  at: 3 put: '-dBATCH' ;
  at: 4 put: '-dSAFER' ;
  at: 5 put: '-sDEVICE=pdfwrite' ;
  at: 6 put: '-sOutputFile=m:\out.pdf' ;
  at: 7 put: '-c' ;
  at: 8 put: '.setpdfwrite';
  at: 9 put: '-f' ;
  at: 10 put: 'm:\escher.ps'.
				
anInstance := MSKGSWrapper new initialize newInstance: nil.
anInstance 
  initWithArgs: anArray ;
  exit; 
  deleteInstance.
About these ads
This entry was posted in Smalltalk and tagged , . Bookmark the permalink.

5 Responses to VASmalltalk – Example wrapper for Ghostscript-dll

  1. Ishaan says:

    Hello Experts,

    I am new to Smalltalk but just want to test this Create PDF functionality using Ghost dll. but not successful so far.
    When I am trying to run the above script..after copied in to Ghost.dll in to my VA CLIENT folder

    It looks like nil never got initialized in the above script..

    anInstance := MSKGSWrapper new initialize newInstance: nil.
    anInstance
    initWithArgs: anArray ;
    exit;
    deleteInstance.

    Can any one help me to understand what am I doing wrong. Much appreciated.

    I got the following error message, Primitive Failed in : PlatformFunction>>callwith:with:with: due to OS error4.

    Please help me.

    Thanks

    • schrievkrom says:

      Well, I just tried that and it worked here:

      a) copy gsdll32.dll to the bin folder of your VA installation
      b) executing “MSKGSWrapper new initialize newInstance: nil.” should give you an instance and no error …

      And you need a full installation of Ghostscript on your computer …

      Marten

      • Ishaan says:

        Thanks Marten for your reply. I really appreciated.

        I tried and still I got the same error.

        Do I need to change any settings or add path in your wrapper/my environment variables.
        Also do I need to bind gsdll32.dll

        I am using VA 4.5
        The wrapper I am using version 0.4 of MSKGhostscriptWrapperApp
        and 1.1 of MSKPlatformExtension 1.1

        Script I am using is:
        | anInstance anArray |

        anArray := Array new: 10.
        anArray
        at: 1 put: ‘ps2pdf’ ;
        at: 2 put: ‘-dNOPAUSE’ ;
        at: 3 put: ‘-dBATCH’ ;
        at: 4 put: ‘-dSAFER’ ;
        at: 5 put: ‘-sDEVICE=pdfwrite’ ;
        at: 6 put: ‘-sOutputFile=c:\out.pdf’ ;
        at: 7 put: ‘-c’ ;
        at: 8 put: ‘.setpdfwrite’;
        at: 9 put: ‘-f’ ;
        at: 10 put: ‘c:\escher.ps’.

        anInstance := MSKGSWrapper new initialize newInstance: nil.
        anInstance
        initWithArgs: anArray ;
        exit;
        deleteInstance

        Please let me know.

        Thanks again.

      • schrievkrom says:

        The only thing I know here is:

        -> VA has found gsdll32.dll – otherwise it would have thrown OSError 126

        but it has thrown OSError 4, which seams to indicate, that a file is NOT found. The only imported libraries are user32, winspool, ws2_32, comdlg32, kernel32, gdi32, advapi32

        I deinstalled gs902 (saved only gsdll32.dll and escher.ps) and even then the output was generated.

        I installed 9.04 and this also works.

        I am using it under Windows 7/64 Bit with 32-Bit Ghostscript.

        Therefore I have no idea – but you should use the latest config maps available:

        MSHGhostscriptInterface 0.4
        MSKPlatformExtension 1.20

  2. Pingback: VASmalltalk – PDF, Images and Ghostscript | Schrievkrom

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s