使用GhostscriptProcessor创建PDF / A.

我想使用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 gsArgs = new List(); 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 gsArgs = new List(); 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(); }