private void ButtonGenerate_Click(object sender, EventArgs e) { try { string inputPath = this.textBoxInputPath.Text; string outputPath = this.textBoxOutputPath.Text; int page = (int)this.numericUpDownPage.Value; int resolution = (int)this.numericUpDownResolution.Value; GhostscriptDevices device = (GhostscriptDevices)this.comboBoxDevice.SelectedItem; GhostscriptPageSizes pageSize = (GhostscriptPageSizes)this.comboBoxPageSize.SelectedItem; GhostscriptSettings ghostscriptSettings = new GhostscriptSettings { Page = new GhostscriptPages { Start = page, End = page }, Device = device, Resolution = new Size(resolution, resolution), Size = new GhostscriptPageSize { Native = pageSize } }; GhostscriptWrapper.GenerateOutput(inputPath, outputPath, ghostscriptSettings); Process.Start(outputPath); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }
private static void PdfToJpg(string path, string fileName, GhostscriptDevices devise, GhostscriptPageSizes pageFormat, int qualityX, int qualityY) { var settingsForConvert = new GhostscriptSettings { Device = devise }; var pageSize = new GhostscriptPageSize { Native = pageFormat }; settingsForConvert.Size = pageSize; settingsForConvert.Resolution = new System.Drawing.Size(qualityX, qualityY); GhostscriptWrapper.GenerateOutput(path, @"C:\YR\Receipt\" + fileName + "_" + ".jpg", settingsForConvert); // here you could set path and name for out put file. }
public static IEnumerable<String> GetDefaultArgs(GhostscriptDevices device) { switch (device) { case GhostscriptDevices.jpeg: return new String[] { "-dAlignToPixels=0", "-dGridFitTT=0", "-dTextAlphaBits=4", "-dGraphicsAlphaBits=4" }; default: return new String[0]; } }
public static IEnumerable <String> GetDefaultArgs(GhostscriptDevices device) { switch (device) { case GhostscriptDevices.jpeg: return(new String[] { "-dAlignToPixels=0", "-dGridFitTT=0", "-dTextAlphaBits=4", "-dGraphicsAlphaBits=4" }); default: return(new String[0]); } }