//===================================================================== /// <summary> /// Rasterises a PDF into selected format /// </summary> /// <param name="inputPath">PDF file to convert</param> /// <param name="outputPath">Destination file</param> /// <param name="command">Conversion settings</param> public static void GenerateOutput(string inputPath, string outputPath, GhostscriptCommand command) { command.InputPath = inputPath; command.OutputPath = outputPath; GhostscriptDLL.CallAPI(command.GetArgs()); return; }
//===================================================================== //===================================================================== // // PUBLIC FUNCTIONS // //===================================================================== //===================================================================== //===================================================================== /// <summary> /// Generates a collection of thumbnail jpgs for the pdf at the input path /// starting with firstPage and ending with lastPage. /// Put "%d" somewhere in the output path to have each of the pages numbered /// </summary> public static void GeneratePageThumbs(string inputPath, string outputPath, int firstPage, int lastPage, int dpix, int dpiy, int width, int height, string format = "png") { GhostscriptCommand command = new GhostscriptCommand(); switch (format.ToLower()) { case "png": command.Device = GhostscriptDevices.png16m; break; case "jpeg": command.Device = GhostscriptDevices.jpeg; break; default: command.Device = GhostscriptDevices.UNDEFINED; break; } command.InputPath = inputPath; command.OutputPath = outputPath; command.Pages.Start = firstPage; command.Pages.End = lastPage; command.Resolution = new System.Drawing.Size(dpix, dpiy); command.Size = new GhostscriptPageSize(); if (width == 0 && height == 0) { command.Size.Native = GhostscriptPageSizes.a7; } else { command.Size.Manual = new System.Drawing.Size(width, height); } GhostscriptDLL.CallAPI(command.GetArgs()); return; }