Creating PDF/A with GhostscriptProcessor

南笙酒味 提交于 2019-12-02 06:48:55

问题


I want to convert a PDF file into PDF/A with GhostscriptProcessor, but the result is a PDF not PDF/A.

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

And the method:

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();
}

If I use gswin32.exe from the commandline the result is a PDF/A file.


回答1:


First switch is ignored. You need to add dummy switch at position 0 so the code will look like:

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();
}


来源:https://stackoverflow.com/questions/25202577/creating-pdf-a-with-ghostscriptprocessor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!