0

I've converted some pdf files to jpg using Ghostscrpt. All is good, but the images are horizontal. How do I change the image orientation?

Source Code:

[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");
    }
miniacz
  • 27
  • 4
  • What Ghostscript.NET version do you use? Is your PDF horizontal? – HABJAN Aug 04 '14 at 11:58
  • Possible duplicate please see http://stackoverflow.com/questions/25075959/how-to-change-image-orientation – Izekid Aug 04 '14 at 12:08
  • @HABJAN v.1.1.9. Yes, my jpgs from pdf are horizontal and I want to get this in vertical. – miniacz Aug 04 '14 at 14:09
  • @miniacz: are original PDF pages (not the output) horizontal or vertical? – HABJAN Aug 04 '14 at 14:31
  • My PDF is a Power Point save as PDF file, so pages are horizontal. After conversion to .jpg, file is rotated. Before(it's a PDF page): http://zapodaj.net/889b9f6aef81e.png.html . After(it's a JPG file from PDF page): http://zapodaj.net/8c8d7ea10f52d.jpg.html I don't know why images which I receive are in this orientation... – miniacz Aug 04 '14 at 14:51

1 Answers1

2

Ok I found a solution of this problem.

  1. Upgrade Ghostscript.NET to v 1.1.9
  2. Upgrade native Ghostscript library to 9.14 version.
miniacz
  • 27
  • 4