c# - 使用 GhostscriptProcessor 创建 PDF/A

标签 c# visual-studio-2010 ghostscript pdfa ghostscript.net

我想使用 GhostscriptProcessor 将 PDF 文件转换为 PDF/A,但结果是 PDF,而不是 PDF/A。

GhostscriptProcessor gsproc = new GhostscriptProcessor(Properties.Resources.gsdll32);
gsproc.StartProcessing(CreatePDFA(@"C:\test\PDF.pdf", @"C:\test\PDFA.pdf"), new GsStdio());

方法:

CreateTestArgs(string inputPath, string outputPath)
{
    List<string> gsArgs = new List<string>();
    gsArgs.Add("-dPDFA");
    gsArgs.Add("-dBATCH");
    gsArgs.Add("-dNOPAUSEgsArgs");
    gsArgs.Add("-sDEVICE=pdfwrite");
    gsArgs.Add(@"-sOutputFile=" + outputPath);
    gsArgs.Add(@"-f" + inputPath);
    return gsArgs.ToArray();
}

如果我从命令行使用 gswin32.exe,结果是一个 PDF/A 文件。

最佳答案

第一个开关被忽略。您需要在位置 0 添加虚拟开关,因此代码如下所示:

string[] CreateTestArgs(string inputPath, string outputPath)
{
    List<string> gsArgs = new List<string>();
    gsArgs.Add("-notused");
    gsArgs.Add("-dPDFA");
    gsArgs.Add("-dBATCH");
    gsArgs.Add("-dNOPAUSEgsArgs");
    gsArgs.Add("-sDEVICE=pdfwrite");
    gsArgs.Add(@"-sOutputFile=" + outputPath);
    gsArgs.Add(@"-f" + inputPath);
    return gsArgs.ToArray();
}

关于c# - 使用 GhostscriptProcessor 创建 PDF/A,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25202577/

相关文章:

visual-studio-2010 - 没有构造函数的实例与参数列表匹配

Ghostscript BoundingBox 值

c# - Ajax 请求在 HandleUnauthorizedRequest 之前命中错误函数

c# - Xamarin 表单选择器级联

visual-studio - 从 Visual Studio 2008 到 Visual Studio 2010 Express Edition

c++ - 如何在 Visual Studio 中调试错误的调用堆栈

c# - 异步设置 Thread.CurrentPrincipal?

c# - 在我的 WCF 服务上调用 close() 会释放所有资源吗?

pdf - ps2pdf : preserve page size

pdf - Ghostscript灰度转换仍然包含颜色?