【发布时间】:2020-01-30 21:01:05
【问题描述】:
我有一个编程任务。我需要使用免费库或命令行程序使用 C# 将 pdf 转换为图像。
到目前为止,使用 Ghostscript 进行转换是可行的,只是它会在图像中心创建一个 8 个红色框:
pdf的内容只有纯白色,但为什么我的图像上有8个红色框?我做错了什么?
代码如下:
string outputImagesPath = null;
string inputPDFFile = null;
inputPDFFile = @"C:\Users\user\cover.pdf";
outputImagesPath = @"C:\user\Desktop\1.jpg";
string ghostScriptPath = @"C:\Users\gswin32.exe";
String ars = "-o" + outputImagesPath+ "%03d.png -sDEVICE=jpeg -dJPEGQ=100 " + inputPDFFile;
Process proc = new Process();
proc.StartInfo.FileName = ghostScriptPath;
proc.StartInfo.Arguments = ars;
proc.StartInfo.CreateNoWindow = true;
//proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string strOutput = proc.StandardOutput.ReadToEnd();
Console.WriteLine(strOutput);
proc.WaitForExit();
这里是pdf的链接,谢谢https://drive.google.com/open?id=0B0auNx4EZsCUUkFHWGR4MjV5NzA
【问题讨论】:
-
我相信你的错误在这里
+ outputImagesPath+ "%03d.png。不应该是+ outputImagesPath+ "%d.jpeg吗?
标签: c# ghostscript