2009-11-13 91 views

回答

3

请尝试从命令行运行此命令以测试它是否正在执行您所需的操作。

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

A Simple C# Wrapper for Ghostscript

+0

嗨,我现在使用gsdll32.dll,所以没有gswin32.exe可用。我必须调用gsapi_init_with_args。从GhostScript网站,我得到了这样的: gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sDEVICE = pdfwrite -sOutputFile = out-x3.pdf PDFA_def.ps input.pdf 但是当我使用参数与gsapi_init_with_args结果PDF不正确,它报告它不符合任何标准。所以这很棘手。任何人都可以帮忙 – imgen 2009-11-13 04:57:16

+0

其实它并不棘手,我给你一个命令行gswin32.exe为了确保-dPDFA和其余的交换机正常工作,你应该有你的安装gswin32.exe,因为我看到你'使用ghostscript获胜。只需运行我给你的线路来检查它是否有效。在你确定命令有效之后,你可以将它翻译成gsapi_init_with_args调用 问候 – 2009-11-13 14:23:15

0

取决于你的检查工具做报告什么确切的偏离标准......您可能需要改变你的PDFA_def.ps以适应你的环境(和您可能需要动态地重新写入的内容文件为每个新的PDF/A转换)。这是一个简短的文件,很好的评论。

尝试添加-Ic:/路径/到/ gsinstalldir/lib目录PDFA_def.ps到命令行哔叽直接调用提示:

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

 
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 

测试命令行第一,然后按照推荐的方式进行。

1

我已经受够了工作使用从ghostscriptsharp如下:

[DllImport("gsdll32.dll", EntryPoint = "gsapi_new_instance")] 
private static extern int CreateAPIInstance(out IntPtr pinstance, IntPtr caller_handle); 

[DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")] 
private static extern int InitAPI(IntPtr instance, int argc, string[] argv); 

[DllImport("gsdll32.dll", EntryPoint = "gsapi_exit")] 
private static extern int ExitAPI(IntPtr instance); 

[DllImport("gsdll32.dll", EntryPoint = "gsapi_delete_instance")] 
private static extern void DeleteAPIInstance(IntPtr instance); 

    private static void CallAPI(string[] args) 
    { 
     IntPtr gsInstancePtr; 
     lock (resourceLock) 
     { 
      CreateAPIInstance(out gsInstancePtr, IntPtr.Zero); 
      try 
      { 
       int result = InitAPI(gsInstancePtr, args.Length, args); 

       if (result < 0) 
       { 
        throw new ExternalException("Ghostscript conversion error", result); 
       } 
      } 
      finally 
      { 
       Cleanup(gsInstancePtr); 
      } 
     } 
    } 

    private static object resourceLock = new object(); 

    private static void Cleanup(IntPtr gsInstancePtr) 
    { 
     ExitAPI(gsInstancePtr); 
     DeleteAPIInstance(gsInstancePtr); 
    } 

args会像字符串数组:

  • “-sDEVICE = pdfwrite”
  • “-dPDFA “
  • ...
相关问题