views:

684

answers:

2

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, i'm using C#.

+1  A: 

pls, try to run this from the command line to test if it's doing what you need.

gswin32.exe -dPDFA -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=PDFA.pdf 1.pdf

A Simple C# Wrapper for Ghostscript

serge_gubenko
Hi, I'm now using gsdll32.dll so no gswin32.exe is available. I have to call the gsapi_init_with_args. from the GhostScript website, i got something like this:gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sDEVICE=pdfwrite -sOutputFile=out-x3.pdf PDFA_def.ps input.pdfbut when I use the arguments with gsapi_init_with_args the result PDF isn't right, it reports that it doesn't conform to any standard. So it's tricky. Anyone can help.
imgen
in fact it's not tricky at all, I gave you a command line for gswin32.exe in order to make sure -dPDFA and the rest of switches are working fine for you, you should have gswin32.exe with your installation as I see you're using ghostscript for win. Just run the line I gave you to check if it works. After you're shure the command works you can translate it into the gsapi_init_with_args callregards
serge_gubenko
A: 

Depends on what exact deviation from the standard your checker tools do report... You may need to alter your PDFA_def.ps to fit your environment (and you may need to dynamically re-write that file for every new PDF/A conversion). It's a short file, and well commented.

Try to add -Ic:/path/to/gsinstalldir/lib and the direct invocation of PDFA_def.ps to the commandline serge suggested:

 gswin32c.exe ^
    -Ic:/path/to/gsinstalldir/lib ^
    -dPDFA ^
    -dBATCH ^
    -dNOPAUSE ^
    -dUseCIEColor ^
    -sDEVICE=pdfwrite ^
    -sOutputFile=output-PDFA.pdf ^
    PDFA_def.gs ^
    input.pdf

or

 gswin32c.exe ^
    -Ic:/path/to/gsinstalldir/lib ^
    -dPDFA ^
    -dBATCH ^
    -dNOPAUSE ^
    -dUseCIEColor ^
    -sDEVICE=pdfwrite ^
    -sOutputFile=output-PDFA.pdf ^
    c:/path/to/customized/PDFA_def.gs ^
    input.pdf

Test commandline first, then do as serge recommended.

pipitas