Creating PDF/A with GhostscriptProcessor

本文关键字:with GhostscriptProcessor PDF Creating | 更新日期: 2023-09-27 18:17:01

我想用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文件

Creating PDF/A with GhostscriptProcessor

忽略第一个开关。您需要在位置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();
}