/// <summary> /// /// </summary> /// <param name="pdfFile"></param> /// <param name="pngDir"></param> /// <returns></returns> /// <example> /// @"C:\IMAGES\PORTUGAL\New folder\OA_24993.pdf".DrawToImage("C:\\TEST"); /// </example> public static List <FileInfo> DrawToImage(this FileInfo pdfFile, int dpi) { // @"C:\PROJECTS\VPrint2\Others\gsdll32.dll"; lock (typeof(oLock)) { GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(sm_DLLPath); var files = new List <FileInfo>(); using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(pdfFile.FullName, gvi, false); var pngDir = pdfFile.Directory; for (int i = 1; i <= rasterizer.PageCount; i++) { var path = pngDir.CombineFileName(string.Concat(pdfFile.GetFileNameWithoutExtension(), '.', i, ".jpg")); files.Add(path); Global.IgnoreList.Add(path.FullName); using (Image img = rasterizer.GetPage(dpi, dpi, i)) img.Save(path.FullName, ImageFormat.Jpeg); } return(files); } } }
public void PrintPdf(string inputfile) { GhostscriptVersionInfo _lastInstalledVersion = GetGhostscriptVersion(); string printerName = System.Drawing.Printing.PrinterSettings.InstalledPrinters.Cast <string>().ToList().Find(f => f.Contains("XPS")); using (GhostscriptProcessor processor = new GhostscriptProcessor(_lastInstalledVersion)) { List <string> switches = new List <string> { "-empty", "-dPrinted", "-dBATCH", "-dNOPAUSE", "-dNOSAFER", "-dNumCopies=1", "-sDEVICE=mswinpr2", "-sOutputFile=%printer%" + printerName, "-f", inputfile }; processor.StartProcessing(switches.ToArray(), null); } }
public void Start() { // there can be multiple Ghostscript versions installed on the system // and we can choose which one we will use. In this sample we will use // the last installed Ghostscript version. We can choose if we want to // use GPL or AFPL (commercial) version of the Ghostscript. By setting // the parameters below we told that we want to fetch the last version // of the GPL or AFPL Ghostscript and if both are available we prefer // to use GPL version. _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion(); // create a new instance of the viewer _viewer = new GhostscriptViewer(); // set the display update interval to 10 times per second. This value // is milliseconds based and updating display every 100 milliseconds // is optimal value. The smaller value you set the rasterizing will // take longer as DisplayUpdate event will be raised more often. _viewer.ProgressiveUpdateInterval = 100; // attach three main viewer events _viewer.DisplaySize += new GhostscriptViewerViewEventHandler(_viewer_DisplaySize); _viewer.DisplayUpdate += new GhostscriptViewerViewEventHandler(_viewer_DisplayUpdate); _viewer.DisplayPage += new GhostscriptViewerViewEventHandler(_viewer_DisplayPage); // open PDF file using the last Ghostscript version. If you want to use // multiple viewers withing a single process then you need to pass 'true' // value as the last parameter of the method below in order to tell the // viewer to load Ghostscript from the memory and not from the disk. _viewer.Open("E:\test\test.pdf", _lastInstalledVersion, false); }
public List <ImageBinary> Export(Stream streamPDF, List <int> listPage) { try { GhostscriptVersionInfo _lastInstalledVersion = null; GhostscriptRasterizer _rasterizer = null; int desired_x_dpi = 300; int desired_y_dpi = 300; _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion( GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL); _rasterizer = new GhostscriptRasterizer(); _rasterizer.Open(streamPDF, _lastInstalledVersion, true); List <ImageBinary> imgBi = new List <ImageBinary>(); foreach (int pageNumber in listPage) { Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); imgBi.Add(new ImageBinary { page_no = pageNumber, img = imageToByteArray(img) }); } _rasterizer.Dispose(); return(imgBi); } catch { return(new List <ImageBinary>()); } }
/// <summary> /// Converts given PDF file to any image format /// </summary> /// <param name="inputPdfPath">Initial pdf file full path</param> /// <param name="fileName">pdf file name</param> /// <param name="outputPath">destination path for saving converted image</param> /// <param name="imageFormat">image format: bmp, jpg, etc.</param> /// <returns></returns> public List <string> Convert(string inputPdfPath, string fileName, string outputPath, ImageFormat imageFormat) { int desired_x_dpi = 96; int desired_y_dpi = 96; var convertedImages = new List <string>(); _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion( GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL); _rasterizer = new GhostscriptRasterizer(); _rasterizer.Open(inputPdfPath, _lastInstalledVersion, false); for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++) { var pageFileName = string.Format("{0}-Page-{1}.{2}", fileName, pageNumber, imageFormat); //fileName + "-Page-" + pageNumber.ToString() + "." + imageFormat; var pageFilePath = Path.Combine(outputPath, pageFileName); Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath, imageFormat); convertedImages.Add(pageFilePath); } return(convertedImages); }
private static void ConvertPdfToImage(ConvertPdfOptions options) { string dll = GetGhostScriptDllPath(); GhostscriptVersionInfo version = new GhostscriptVersionInfo(new System.Version(0, 0, 0), dll, string.Empty, GhostscriptLicense.GPL); using (GhostscriptRasterizer gs = new GhostscriptRasterizer()) { gs.Open(options.inputFile, version, false); if (gs.PageCount > 0) { int dpi = options.quality * 3; using (Image image = gs.GetPage(dpi, dpi, options.pageNumber)) { int imageWidth = image.Width; if (options.maxWidth > 0 && options.maxWidth < imageWidth) { double ratio = (double)options.maxWidth / imageWidth; int maxHeight = Convert.ToInt32(Math.Round(ratio * image.Height)); using (Image thumb = ResizeImage(image, options.maxWidth, maxHeight)) { SaveImage(thumb, options.outputFile); } } else { SaveImage(image, options.outputFile); } } } gs.Close(); } }
public static byte[] PdfToTiff(Stream data, int i, string datafilelocation) { string path64 = (SolutionPath + "\\gsdll64.dll"); string path32 = (SolutionPath + "\\gsdll32.dll"); try { GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(path64); using (var pdfengine = new GhostscriptRasterizer()) { pdfengine.Open(data, gvi, true); var image = pdfengine.GetPage(300, 300, i); var outputPngPath = Path.Combine(string.Format(datafilelocation, i, "tiff")); var result = new MemoryStream(); image.Save(result, System.Drawing.Imaging.ImageFormat.Tiff); result.Position = 0; return(result.ToArray()); } } catch { GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(path32); using (var pdfengine = new GhostscriptRasterizer()) { pdfengine.Open(data, gvi, true); var image = pdfengine.GetPage(300, 300, i); var outputPngPath = Path.Combine(string.Format(datafilelocation, i, "tiff")); var result = new MemoryStream(); image.Save(result, System.Drawing.Imaging.ImageFormat.Tiff); result.Position = 0; return(result.ToArray()); } } }
static void Main(string[] args) { string inFile = args[0]; string outFile = args[1]; string[] pages = new string[args.Length - 2]; for (int i = 2; i < args.Length; i++) { pages[i - 2] = args[i]; } Console.WriteLine(); GhostscriptProcessor gp = new GhostscriptProcessor(GhostscriptVersionInfo.GetLastInstalledVersion(), true); foreach (string p in pages) { gp.Processing += GPProcess; gp.StartProcessing(GSExtractSwitches(inFile, "temp" + p + ".pdf", p), null); while (gp.IsRunning) { } } gp.Processing += GPProcess; gp.StartProcessing(GSCombineSwitches(pages, outFile), null); while (gp.IsRunning) { } foreach (string p in pages) { DeleteTempFiles(p); } }
private static void OptimizarDump() { var dump = Directory.GetCurrentDirectory() + @"\dump"; var dumped = Directory.GetCurrentDirectory() + @"\dumped"; GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(Directory.GetFiles(Directory.GetCurrentDirectory(), "gsdll32.dll").FirstOrDefault()); using (GhostscriptProcessor processor = new GhostscriptProcessor(gvi, true)) { //processor.Processing += new GhostscriptProcessorProcessingEventHandler(processor_Processing); List <string> switches = new List <string>(); switches.Add("-empty"); //switches.Add("-dSAFER"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOPROMPT"); //switches.Add(@"-sFONTPATH=" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts)); //switches.Add("-dFirstPage=" + pageFrom.ToString()); //switches.Add("-dLastPage=" + pageTo.ToString()); switches.Add("-sDEVICE=pdfwrite"); switches.Add("-CompressPages=true"); switches.Add("-dCompatibilityLevel=1.5"); switches.Add("-dPDFSETTINGS=/ebook"); switches.Add("-dEmbedAllFonts=false"); switches.Add("-dSubsetFonts=false"); switches.Add(@"-sOutputFile=" + dumped); switches.Add(@"-f"); switches.Add(dump); // if you dont want to handle stdio, you can pass 'null' value as the last parameter //LogStdio stdio = new LogStdio(); processor.StartProcessing(switches.ToArray(), null); } }
//Methode FONCTIONNELLE de conversion de pdf en images public static List <System.Drawing.Image> exportPdfToImages(string file) { string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); List <System.Drawing.Image> output = new List <System.Drawing.Image>(); System.Drawing.Image img; GhostscriptRasterizer rasterizer = null; GhostscriptVersionInfo vesion = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\gsdll32.dll", string.Empty, Ghostscript.NET.GhostscriptLicense.GPL); using (rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(file, vesion, false); for (int i = 1; i <= rasterizer.PageCount; i++) { img = rasterizer.GetPage(200, 200, i); Bitmap b = new Bitmap(img, new System.Drawing.Size(1654, 2339)); output.Add(b); } rasterizer.Close(); } return(output); }
public ActionResult GenerateJpeg(string signature) { MemoryStream pdfStream = this.CreateSignedPDF(signature); int desired_x_dpi = 96; int desired_y_dpi = 96; //Reference to Ghostscript string path = Server.MapPath("~/Libs/gsdll32.dll"); GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(@path); using (var rasterizer = new GhostscriptRasterizer()) { rasterizer.Open(pdfStream, gvi, true); //Only get first page var img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, 1); MemoryStream imageStream = new MemoryStream(); img.Save(imageStream, ImageFormat.Jpeg); pdfStream.Dispose(); var imageContent = imageStream.ToArray(); imageStream.Dispose(); return(File(imageContent, "image/jpeg", "signed.jpeg")); } }
public void Open(string path, GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (String.IsNullOrWhiteSpace(path)) { throw new FileNotFoundException("Input file is NULL.", path); } path = Path.GetFullPath(path).Replace("\\", "/"); if (!File.Exists(path)) { throw new FileNotFoundException("Could not find input file.", path); } if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } this.Close(); _filePath = path; _interpreter = new GhostscriptInterpreter(versionInfo, dllFromMemory); this.Open(); }
public void Start() { int desired_x_dpi = 96; int desired_y_dpi = 96; string inputPdfPath = @"E:\gss_test\test.pdf"; string outputPath = @"E:\gss_test\output\"; _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion(); using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer()) { /* MemoryStream usage sample * * byte[] buffer = File.ReadAllBytes(inputPdfPath); * MemoryStream ms = new MemoryStream(buffer); * * _rasterizer.Open(ms); * */ rasterizer.Open(inputPdfPath, _lastInstalledVersion, false); for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++) { string pageFilePath = Path.Combine(outputPath, "Page-" + pageNumber.ToString() + ".png"); Image img = rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath, ImageFormat.Png); Console.WriteLine(pageFilePath); } } }
private void Export(string inputPDFFile, string outputImagesPath) { try { GhostscriptVersionInfo _lastInstalledVersion = null; GhostscriptRasterizer _rasterizer = null; int desired_x_dpi = 96; int desired_y_dpi = 96; _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion( GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL); _rasterizer = new GhostscriptRasterizer(); _rasterizer.Open(inputPDFFile, _lastInstalledVersion, false); for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++) { string pageFilePath = Path.Combine(outputImagesPath, "Page-" + pageNumber.ToString("00") + ".jpg"); Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); img.Save(pageFilePath, ImageFormat.Jpeg); } _rasterizer.Dispose(); } catch { } }
protected List <string> PdfToImages(string file, string outputDir, int dpi) { try { List <string> fileNames = new List <string>(); Ghostscript.NET.Rasterizer.GhostscriptRasterizer rasterizer = null; string gsDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Binaries\gsdll32.dll"); GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(gsDllPath); using (rasterizer = new Ghostscript.NET.Rasterizer.GhostscriptRasterizer()) { rasterizer.Open(file, gvi, true); for (int i = 1; i <= rasterizer.PageCount; i++) { System.Drawing.Image img = rasterizer.GetPage(dpi, dpi, i); string fileName = Path.Combine(outputDir, string.Format("{0}.jpg", i)); img.Save(fileName, ImageFormat.Jpeg); fileNames.Add(fileName); } rasterizer.Close(); } return(fileNames); } catch (Exception ex) { //potentially log the exception throw; } }
private void Process(string input, string output, int startPage, int endPage) { GhostscriptVersionInfo _gs_verssion_info = GhostscriptVersionInfo.GetLastInstalledVersion(); Ghostscript.NET.Processor.GhostscriptProcessor processor = new Ghostscript.NET.Processor.GhostscriptProcessor(_gs_verssion_info, true); processor.StartProcessing(CreateTestArgs(input, output, startPage, endPage), new ConsoleStdIO(true, true, true)); }
public bool ConvertPsToPdf(string inputFile, string outputFile) { GhostscriptVersionInfo gv = GhostscriptVersionInfo.GetLastInstalledVersion(); try { using (GhostscriptProcessor processor = new GhostscriptProcessor(gv, true)) { processor.Processing += new GhostscriptProcessorProcessingEventHandler(processor_Processing); List <string> switches = new List <string>(); switches.Add("-empty"); switches.Add("-dQUIET"); switches.Add("-dSAFER"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOPROMPT"); switches.Add("-sDEVICE=pdfwrite"); switches.Add("-dCompatibilityLevel=1.4"); switches.Add("-sOutputFile=" + outputFile); switches.Add("-c"); switches.Add("-f"); switches.Add(inputFile.ToString()); processor.StartProcessing(switches.ToArray(), null); } } catch (Exception) { return(false); } return(true); }
public List <string> ConvertPdfJpg() { Guid guid = Guid.NewGuid(); string oldFileName = tbFileName.Text; string newFileName = tmpPath + "tmp_watermake_" + guid + ".pdf"; File.Copy(oldFileName, newFileName); string outFileName = Path.GetFileName(newFileName); List <string> outFiles = new List <string>(); GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(localGhostscriptDll); using (GhostscriptRasterizer rasterizer = new GhostscriptRasterizer()) { /*rasterizer.CustomSwitches.Add("-r200x300"); * rasterizer.CustomSwitches.Add("-dAutoRotatePages =/ None");*/ rasterizer.Open(newFileName, gvi, false); for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++) { string outNameFile = tmpPath + outFileName.Replace(".pdf", "") + "_" + pageNumber.ToString() + ".jpeg"; outFiles.Add(outNameFile); Image img = rasterizer.GetPage(300, 300, pageNumber); img.Save(outNameFile, ImageFormat.Jpeg); } rasterizer.Close(); } return(outFiles); }
public void Start() { // For users who distribute their gsdll32.dll or gsdll64.dll with their application: Ghostscript.NET by default // peeks into the registry to collect all installed Ghostscript locations. If you want to use ghostscript dll from // a custom location, it's recommended to do something like this: GhostscriptVersionInfo gvi = new GhostscriptVersionInfo( new Version(0, 0, 0), @"e:\dumyfolder\myapplication\gsdll32.dll", string.Empty, GhostscriptLicense.GPL); // and then pass that GhostscriptVersionInfo to required constructor or method // sample #1 GhostscriptProcessor proc = new GhostscriptProcessor(gvi); // sample #2 GhostscriptRasterizer rast = new GhostscriptRasterizer(); rast.Open("test.pdf", gvi, true); // sample #3 GhostscriptViewer view = new GhostscriptViewer(); view.Open("test.pdf", gvi, true); }
static string PDFToImage(MemoryStream inputMS, int dpi) { string base64String = ""; GhostscriptRasterizer rasterizer = new GhostscriptRasterizer(); GhostscriptVersionInfo version = new GhostscriptVersionInfo( new Version(0, 0, 0), @"C:\Program Files\gs\gs9.20\bin\gsdll64.dll", string.Empty, GhostscriptLicense.GPL ); try { rasterizer.Open(inputMS, version, false); for (int i = 1; i <= rasterizer.PageCount; i++) { MemoryStream ms = new MemoryStream(); Image img = rasterizer.GetPage(dpi, dpi, 1); img.Save(ms, ImageFormat.Jpeg); ms.Close(); base64String = Convert.ToBase64String((byte[])ms.ToArray()); } rasterizer.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(base64String); }
/// <summary> /// Convert a bdf to an array bytes in order to save a picture /// </summary> /// <param name="upload"></param> /// <returns></returns> public static byte[] ConvertPdfToPngBytes(FileUpload upload) { byte[] fileBytes = null; try { int desired_x_dpi = 96; int desired_y_dpi = 96; var _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL); var _rasterizer = new GhostscriptRasterizer(); _rasterizer.Open(upload.File.InputStream, _lastInstalledVersion, true); List <Image> images = new List <Image>(); int maxWidth = 0; int totalHeight = 0; int pageCount = _rasterizer.PageCount > 1 ? 2 : 1; for (int pageNumber = 1; pageNumber <= pageCount; pageNumber++) { Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); maxWidth = maxWidth > img.Width ? maxWidth : img.Width; totalHeight = totalHeight + img.Height + 1; images.Add(img); } _rasterizer.Close(); Bitmap finalImage = new Bitmap(maxWidth, totalHeight, PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(finalImage)) { int startPoint = 0; foreach (Image img in images) { graphics.DrawImage(img, new Rectangle(new Point(0, startPoint), img.Size), new Rectangle(new Point(), img.Size), GraphicsUnit.Pixel); startPoint = startPoint + img.Height + 1; img.Dispose(); } } var imgStream = new MemoryStream(); finalImage.Save(imgStream, ImageFormat.Png); upload.ThumbBytes = GetThumbnailBytes(imgStream, 190); using (var ms = new MemoryStream()) { imgStream.Position = 0; imgStream.CopyTo(ms); fileBytes = ms.ToArray(); } imgStream.Dispose(); finalImage.Dispose(); } catch (Exception e) { Commons.Logger.GenerateError(e, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "UrlPath = " + upload.UploadName); } return(fileBytes); }
public GhostscriptProcessor(GhostscriptVersionInfo version, bool fromMemory) { if (version == null) { throw new ArgumentNullException("version", "Cannot be null."); } _gs = new GhostscriptLibrary(version, fromMemory); }
public GhostscriptProcessor(GhostscriptVersionInfo version, bool fromMemory) { if (version == null) { throw new ArgumentNullException("version"); } _gs = new GhostscriptLibrary(version, fromMemory); }
/// <summary> /// Initializes a new instance of the <see cref="GsNetPdfRender"/> class. /// </summary> /// <param name="pdfStream"> /// The PDF stream. /// </param> /// <param name="resolution"> /// The resolution. /// </param> /// <param name="gsDllPath"> /// The path to the gs dll (to prevent reading from the registry) /// </param> /// <param name="gsLibPath"> /// The path to the gs lib (to prevent reading from the registry) /// </param> /// <param name="gsVersion"> /// gs dll version (to prevent reading from the registry) /// </param> public GsNetPdfRender(byte[] pdfStream, int resolution, Version gsVersion, string gsDllPath, string gsLibPath) { // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags GhostscriptVersionInfo dynamicVersion = new GhostscriptVersionInfo(gsVersion, gsDllPath, gsLibPath, GhostscriptLicense.GPL); this.rasterizer = new GhostscriptRasterizer(); this.rasterizer.Open(new MemoryStream(pdfStream), dynamicVersion, true); this.resolution = resolution; }
public PdfRasterizer() { var ghostDllPath = Path.Combine(GetBinPath(), Environment.Is64BitProcess ? "gsdll64.dll" : "gsdll32.dll"); _versionInfo = new GhostscriptVersionInfo(new Version(0, 0, 0), ghostDllPath, string.Empty, GhostscriptLicense.GPL); _rasterizer = new GhostscriptRasterizer(); }
/// <summary> /// 取得 GhostScript Assembly 版本&資訊 /// </summary> /// <returns></returns> private static GhostscriptVersionInfo GetGhostscriptVersionInfo() { var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var vesion = new GhostscriptVersionInfo(new Version(0, 0, 0), path + @"\gsdll32.dll", string.Empty, GhostscriptLicense.GPL); return(vesion); }
/// CreateProcessor #region CreateProcessor /// <summary> /// Creates ghostscript processor /// </summary> /// <returns>ghostscript processor</returns> private static GhostscriptProcessor CreateProcessor() { GhostscriptVersionInfo gsVersion = new GhostscriptVersionInfo(GetLib()); // create processor and set constructor 'fromMemory' option to true so the app will be able to run multiple instances of the Ghostscript GhostscriptProcessor processor = new GhostscriptProcessor(gsVersion, true); return(processor); }
public void Open(string path) { if (!File.Exists(path)) { throw new FileNotFoundException("Could not find input file.", path); } this.Open(path, GhostscriptVersionInfo.GetLastInstalledVersion(), false); }
public PdfToThumb() { _lastInstalledVersion = GhostscriptVersionInfo.GetLastInstalledVersion( GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL); _rasterizer = new GhostscriptRasterizer(); }
public void Open(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } this.Open(stream, GhostscriptVersionInfo.GetLastInstalledVersion(), false); }
public void Open(string path, GhostscriptVersionInfo versionInfo, bool fromMemory) { this.Close(); _filePath = path; _interpreter = new GhostscriptInterpreter(versionInfo, fromMemory); this.Open(); }
public PdfSupportedFormat() { var currentPath = Directory.GetCurrentDirectory(); var ghostScriptDll = new DirectoryInfo(currentPath).GetFiles("gsdll32.dll", SearchOption.AllDirectories); var meuDll = ghostScriptDll[0].FullName; _gvi = new GhostscriptVersionInfo(new Version(0, 0, 0), meuDll, Empty, GhostscriptLicense.GPL); Format = "PDF Format"; FileExtension = ".pdf"; }
/// <summary> /// Initializes a new instance of the Ghostscript.NET.GhostscriptInterpreter class. /// </summary> /// <param name="version">GhostscriptVersionInfo instance that tells which Ghostscript library to use.</param> public GhostscriptInterpreter(GhostscriptVersionInfo version) : this(version, false) { }
/// <summary> /// Initializes a new instance of the Ghostscript.NET.GhostscriptInterpreter class. /// </summary> /// <param name="version">GhostscriptVersionInfo instance that tells which Ghostscript library to use.</param> /// <param name="fromMemory">Tells if the Ghostscript should be loaded from the memory or directly from the disk.</param> public GhostscriptInterpreter(GhostscriptVersionInfo version, bool fromMemory) { if (version == null) { throw new ArgumentNullException("version"); } // load ghostscript native library _gs = new GhostscriptLibrary(version, fromMemory); // initialize Ghostscript interpreter this.Initialize(); }
public void Open(Stream stream, GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (stream == null) { throw new ArgumentNullException("stream"); } if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } string path = StreamHelper.WriteToTemporaryFile(stream); _fileCleanupHelper.Add(path); this.Open(path, versionInfo, dllFromMemory); }
public void Open(string path, GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (!File.Exists(path)) { throw new FileNotFoundException("Could not find input file.", path); } if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } this.Close(); _filePath = path; _interpreter = new GhostscriptInterpreter(versionInfo, dllFromMemory); this.Open(); }
public void Open(GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } this.Close(); _filePath = string.Empty; _interpreter = new GhostscriptInterpreter(versionInfo, dllFromMemory); this.Open(); }
public void Open(Stream stream, GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (stream == null) { throw new ArgumentNullException("stream"); } if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } if (_gsViewState == null) { _viewer.Open(stream, versionInfo, dllFromMemory); } }
public void Open(string path, GhostscriptVersionInfo versionInfo, bool dllFromMemory) { if (!File.Exists(path)) { throw new FileNotFoundException("Could not find input file.", path); } if (versionInfo == null) { throw new ArgumentNullException("versionInfo"); } if (_gsViewState == null) { _viewer.Open(path, versionInfo, dllFromMemory); } }
public GhostscriptProcessor(GhostscriptVersionInfo version) : this(version, false) { }