我已经使用这个代码10多年了,它突然停止工作。该程序读取一个pdf文件列表,并输出一个包含列表中所有文件的pdf文件。它使用gsapi.pas包装单元。多年来,我只需要从Ghostscript.t下载一个更新版本的gsdll32.dll文件,就可以兼容更新版本的pdf文件格式。但它已经不起作用了
有什么想法吗?
procedure PDFMerge(input : Array of String;output : string);
var
code:integer;
instance:Pointer;
argv:PPChar;
N,I : smallint;
begin
new(instance);
N:=length(input);
setlength(argv,6+N);
code:=gsapi_new_instance(@instance,nil);
if code<>0 then
begin
raise Exception.Create('Impossible to open an instance of ghostscript. Error code: '+IntToStr(code));
end;
try
//try adding dNothing as first parameter argv[1] := pchar('dNothing');
argv[0] := pchar('AppendPdf');
argv[1] := pchar('-dNOPAUSE');
argv[2] := pchar('-dBATCH');
argv[3] := pchar('-dSAFER');
argv[4] := pchar('-sDEVICE=pdfwrite');
argv[5] := pchar('-sOutputFile='+ output);
argv[6] := pchar('-c');
argv[7] := pchar('.setpdfwrite');
argv[8] := pchar('-f');
for I := 0 to N - 1 do
argv[9+I] := pchar(input[I]);
//Call gs32.dll
code := gsapi_init_with_args(instance, length(argv), argv);
if code<0 then
raise Exception.Create('ERROR: init_args: '+IntToStr(code));
gsapi_exit(instance);
gsapi_delete_instance(instance);
finally
end;
end;
我正在使用Ghostscript V10.0。我发现他们有了一个新的翻译,也许这与此有关?虽然我确实尝试了添加开关“-dNEWPDF=false”,但没有运气。我一直收到错误代码-100。
请注意,在Ghostscript中使用等效的命令行本身效果良好。在我看来,他们改变了调用API的方式。这会是什么情况?
如果有任何帮助,我将不胜感激。
我确实尝试了添加开关“-dNEWPDF=false”,但没有成功。