我已经使用Ghostscrpt将一些pdf文件转换为jpg。一切都很好,但图像是水平的。如何更改图像方向?
源代码:
[HttpPost]
public ActionResult PreprocessPDF(string fileTempName)
{
var path = ConfigurationManager.AppSettings["TemporaryDirectory"].ToString();
string file = Path.Combine(path, fileTempName);
System.IO.Directory.CreateDirectory(path + @"\" + fileTempName + "_temp"); // create temporary directory for storing slides
//for pdf's
int desired_x_dpi = 96;
int desired_y_dpi = 96;
_lastInstalledVarsion = GhostscriptVersionInfo.GetLastInstalledVersion();
_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(file, _lastInstalledVarsion, false);
int countSlides = _rasterizer.PageCount;
for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++)
{
string pageFilePath = Path.Combine(path + @"\" + fileTempName + "_temp", "Slide" + pageNumber.ToString() + ".jpg");
Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber);
img.Save(pageFilePath, ImageFormat.Jpeg);
Console.Write(" ");
}
_rasterizer.Close();
return Json(new { success = true, slides = countSlides }, "json/application");
}
答案 0 :(得分:2)
好的,我找到了解决这个问题的方法。