Open k9215105 opened 2 years ago
Hi @k9215105 , You can use GhostscriptProcessor from ProcessorSample1.
// call pdf2Png();
static void ghostscript_Processing(object sender, GhostscriptProcessorProcessingEventArgs e)
{
Console.WriteLine(e.CurrentPage.ToString() + " / " + e.TotalPages.ToString());
}
private static void pdf2Png()
{
string inputFile = @"c:\temp\abc.pdf";
string outputFile = @"c:\temp\abc-page-%03d.png";
int pageFrom = 1;
int pageTo = 50;
using (GhostscriptProcessor ghostscript = new GhostscriptProcessor())
{
ghostscript.Processing += new GhostscriptProcessorProcessingEventHandler(ghostscript_Processing);
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dSAFER");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOPROMPT");
switches.Add("-dFirstPage=" + pageFrom.ToString());
switches.Add("-dLastPage=" + pageTo.ToString());
switches.Add("-sDEVICE=png16m");
switches.Add("-r96");
switches.Add("-dTextAlphaBits=4");
switches.Add("-dGraphicsAlphaBits=4");
switches.Add(@"-sOutputFile=" + outputFile);
switches.Add(@"-f");
switches.Add(inputFile);
ghostscript.Process(switches.ToArray());
}
}
It works, thanks for that.
Hi @k9215105 , Could you give us more information about "doesn't work" ?
Sorry, it was a mistake, it works now, thanks
I am using RasterizerSample1 to convert a pdf file to png. The pdf file contains chinese word with font 標楷體(kaiu.tff), which will broken in output file. pdf
png
![image](https://user-images.githubusercontent.com/22118884/143542883-ae1ea58b-2870-4efd-84af-750fd040f689.png)