C# Ghostscript.NET.Rasterizer设置分辨率(Dpi)不工作
我有这个代码将pdf转换为tif,它比ImageMagick库更快,所以我必须使用它。每一个 事情进展顺利,但当我设置x和y dpi时,它总是被忽略。我尝试了不同版本的NuGet GhostScript,也尝试了不同版本的GhostScript.exe,但仍然存在相同的问题 这是我的密码:C# Ghostscript.NET.Rasterizer设置分辨率(Dpi)不工作,c#,asp.net,ghostscript.net,C#,Asp.net,Ghostscript.net,我有这个代码将pdf转换为tif,它比ImageMagick库更快,所以我必须使用它。每一个 事情进展顺利,但当我设置x和y dpi时,它总是被忽略。我尝试了不同版本的NuGet GhostScript,也尝试了不同版本的GhostScript.exe,但仍然存在相同的问题 这是我的密码: var xDpi = 300; //set the x DPI var yDpi = 300; //set the y DPI using (var rast
var xDpi = 300; //set the x DPI
var yDpi = 300; //set the y DPI
using (var rasterizer = new GhostscriptRasterizer()) //create an instance for GhostscriptRasterizer
{
rasterizer.Open(fileName); //opens the PDF file for rasterizing
int PdfPages = rasterizer.PageCount;
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
{
//set the output image(png's) complete path
string outputPNGPath = Path.Combine(fileNameResultDirectory, "00" + pageNumber.ToString() + ".tif");
//converts the PDF pages to png's
Image pdf2PNG = rasterizer.GetPage(xDpi, yDpi, pageNumber);//it gets ignored here.
//save the png's
pdf2PNG.Save(outputPNGPath, ImageFormat.Tiff);
}
}
还尝试:
rasterizer.CustomSwitches.Add("-r300x300");
private static void Test()
{
var localGhostscriptDll = Path.Combine(Environment.CurrentDirectory, "gsdll64.dll");
var localDllInfo = new GhostscriptVersionInfo(localGhostscriptDll);
int desired_x_dpi = 160;
int desired_y_dpi = 160;
string inputPdfPath = @"d:\d.pdf";
string outputPath = @"d:\Test\test.jpg";
GhostscriptRasterizer _rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(inputPdfPath, localDllInfo, false);
for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++)
{
string pageFilePath = Path.Combine(outputPath, "Page-" + pageNumber.ToString() + ".png");
Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber);
img.Save(pageFilePath, ImageFormat.Png);
}
_rasterizer.Close();
}
private静态无效测试()
{
var localGhostscriptDll=Path.Combine(Environment.CurrentDirectory,“gsdll64.dll”);
var localDllInfo=新GhostscriptVersionInfo(localGhostscriptDll);
int所需的_x_dpi=160;
int所需的_y_dpi=160;
字符串inputPdfPath=@“d:\d.pdf”;
字符串outputPath=@“d:\Test\Test.jpg”;
GhostscriptRasterizer _rasterizer=新的GhostscriptRasterizer();
_打开(inputPdfPath,localDllInfo,false);
对于(int pageNumber=1;pageNumber)