private static string[] GetArgs(string inputFile, string outputFile)
{
return new[] {
$"gs",
$"-o",
$"{outputFile}",
$"-dNoOutputFonts",
$"-sDEVICE=pdfwrite",
$"{inputFile}",
};
GhostscriptProcessor ghostscript = new GhostscriptProcessor();
string inputFile = "D:\\%1.pdf";
string outputFile = "D:\\%output.pdf";
ghostscript.Process(GetArgs(inputFile, outputFile));
there will be an error "An error occured when call to
'gsapi_init_with_args' is made: -100"
but if change the file Path as fellows
string inputFile = "D:\%1.pdf"; (contains %) string outputFile = "D:\output.pdf"; (not contains %)
it works ,no Problem
and if change the file Path as fellows
string inputFile = "D:\你.pdf"; string outputFile = "D:\output.pdf";
the inputFile="D:\你.pdf" "你" is chinese character
this also not work
and i have do more test, if the file Path Contains chinese character ,not works.
anybody can give some advise?thanks a lot .
i do some changes to convert the fileName to UTF8 as fellows
UTF8Encoding utf8 = new UTF8Encoding();
string inputFile = "D:\你.pdf"; string outputFile = "D:\%91.pdf";
Byte[] inputFileEncodedBytes = utf8.GetBytes(inputFile);
Byte[] outPutFileEncodedBytes = utf8.GetBytes(outputFile);
string strInput = System.Text.Encoding.UTF8.GetString(inputFileEncodedBytes);
string strOutPut =System.Text.Encoding.UTF8.GetString(outPutFileEncodedBytes);
ghostscript.Process(GetArgs(strInput , strOutPut ));
the result is the same