我想使用 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/