change image orientation.

Aug 4, 2014 at 2:40 PM
Edited Aug 4, 2014 at 2:42 PM
Hello,
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? First page is looking good: http://zapodaj.net/005238a4895da.jpg.html, but rest of images looks: !http://zapodaj.net/6e13bf687401d.jpg.html

My function above:
[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");
    }
Coordinator
Aug 4, 2014 at 5:18 PM
Hi,

Can you send me the PDF you are trying to convert to jpg?

Cheers,
Josip
Aug 5, 2014 at 10:23 AM
Edited Aug 5, 2014 at 10:42 AM
Aug 6, 2014 at 6:32 AM
Josip,
any suggestions how to resolve this problem?
Coordinator
Aug 6, 2014 at 7:24 AM
Hi,

The code and the PDF works fine for me. Pages are rasterized properly and they are all vertical.

I was testing this with Ghostscript.NET v.1.1.9 and Ghostscript native library 9.14 ( both 64bit ).

What is your environment?

Cheers,
Josip
Aug 6, 2014 at 8:08 AM
Edited Aug 6, 2014 at 8:23 AM
I try again install and I received:
'Ghostscript.NET 1.1.9' already installed.
SlideShare already has a reference to 'Ghostscript.NET 1.1.9'.
But I don't know how to install/download this:
and Ghostscript native library 9.14 ( both 64bit )
Aug 6, 2014 at 8:24 AM
Edited Aug 6, 2014 at 8:26 AM
Ok I found.
I have 8.64 version.
How to upgrade to 9.14 version?
Coordinator
Aug 6, 2014 at 8:32 AM
Yep, that's the problem. You need to install latest native Ghostscript library.

Download and install native Ghostscript library 9.14 from http://www.ghostscript.com/download/gsdnld.html

If you have 64bit system, I would suggest you to install both 32 and 64 bit libraries side by side.

Cheers,
Josip
Aug 6, 2014 at 9:27 AM
Edited Aug 6, 2014 at 9:30 AM
It works:)

Many thanks for your help.

Best regards,
M.
Coordinator
Aug 6, 2014 at 9:45 AM
Great, thanks for letting me know it works.

Cheers,
Josip