Beispiel #1
0
        /// <summary>
        /// Initialize GhostscriptWrapper with relevant parameters for EPS2LowResPDF conversion.
        /// </summary>
        public void InitEPS2LowResPDFConversion()
        {
            Cleanup();

            // Parameters creation.
            List <string> parameters = new List <string>();

            parameters.Add("this is gs command .exe name");                                         // Ghostscript exe command.
            parameters.Add("-dNOPAUSE");                                                            // Do not prompt and pause for each page
            //parameters.Add("-dPDFSETTINGS=/screen");
            parameters.Add("-sDEVICE=pdfwrite");                                                    // Device name.
            parameters.Add("-dEPSFitPage");
            parameters.Add("-dEPSCrop");
            parameters.Add("-r72x72");
            parameters.Add("-dDownsampleColorImages=true");
            parameters.Add("-dDownsampleGrayImages=true");
            parameters.Add("-dDownsampleMonoImages=true");
            parameters.Add("-dColorImageResolution=72");
            parameters.Add("-dGrayImageResolution=72");
            parameters.Add("-dMonoImageResolution=72");
            parameters.Add("-dCompatibilityLevel=1.4");
            parameters.Add("-dDetectDuplicateImages=true");
            parameters.Add("-dAutoRotatePages=/None");
            parameters.Add("-sOutputFile=" + "rip2image_junk_helper");                              // we must set the output at init stage, so we put a junk file, just for the init to successed

            // Create the Ghostscript wrapper.
            m_GhostscriptWrapper = new GhostscriptWrapper();
            m_GhostscriptWrapper.Init(parameters.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Initialize GhostscriptWrapper with relevant parameters for PDF2JPG conversion.
        /// </summary>
        public void InitPDF2JPGConversion()
        {
            Cleanup();

            // Parameters creation.
            List <string> parameters = new List <string>();

            parameters.Add("this is gs command .exe name");              // Ghostscript exe command.
            parameters.Add("-dNOPAUSE");                                 // Do not prompt and pause for each page
            parameters.Add("-sDEVICE=jpeg");                             // what kind of export format i should provide.
            parameters.Add("-dDOINTERPOLATE");

            // Create the Ghostscript wrapper.
            m_GhostscriptWrapper = new GhostscriptWrapper();
            m_GhostscriptWrapper.Init(parameters.ToArray());
        }
Beispiel #3
0
        /// <summary>
        /// Initialize GhostscriptWrapper with relevant parameters for PDF2PNGSingle conversion.
        /// This method convert only the first page of the PDF to PNG.
        /// </summary>
        public void InitPDF2PNGSingleConversion()
        {
            Cleanup();

            // Parameters creation.
            List <string> parameters = new List <string>();

            parameters.Add("this is gs command .exe name");              // Ghostscript exe command.
            parameters.Add("-dNOPAUSE");                                 // Do not prompt and pause for each page
            parameters.Add("-dFirstPage=1");                             // Convert only the first page of the PDF to PNG.
            parameters.Add("-dLastPage=1");                              // Convert only the first page of the PDF to PNG.
            parameters.Add("-sDEVICE=pngalpha");                         // what kind of export format i should provide, in this case "pngalpha" for transparent PNG.
            parameters.Add("-dDOINTERPOLATE");
            parameters.Add("-sOutputFile=" + "rip2image_junk_helper");   // we must set the output at init stage, so we put a junk file, just for the init to successed

            // Create the Ghostscript wrapper.
            m_GhostscriptWrapper = new GhostscriptWrapper();
            m_GhostscriptWrapper.Init(parameters.ToArray());
        }
Beispiel #4
0
        /// <summary>
        /// Convert PDF to EPS.
        /// </summary>
        /// <param name="inPathFileToConvert"></param>
        /// <param name="inOutputFileFullPath"></param>
        /// <param name="inFirstPageToConvert"></param>
        /// <param name="inLastPageToConvert"></param>
        /// <returns></returns>
        public bool ConvertPDF2EPS(string inPathFileToConvert, string inOutputFileFullPath, double inFirstPageToConvert, double inLastPageToConvert)
        {
            // Parameters creation.
            List <string> parameters = new List <string>();

            parameters.Add("this is gs command .exe name");                                       // Ghostscript exe command.
            parameters.Add("-dNOPAUSE");                                                          // Do not prompt and pause for each page
            parameters.Add("-dBATCH");                                                            // Terminate when accomplish.
            parameters.Add("-dFirstPage=" + Convert.ToInt32(inFirstPageToConvert));               // First page to convert in the PDF.
            parameters.Add("-dLastPage=" + Convert.ToInt32(inLastPageToConvert));                 // Last page to convert in the PDF.
            parameters.Add("-sDEVICE=eps2write");                                                 // Device name.
            parameters.Add("-sOutputFile=" + inOutputFileFullPath);                               // Where to write the output.
            parameters.Add(inPathFileToConvert);                                                  // File to convert.

            // Create the Ghostscript wrapper.
            m_GhostscriptWrapper = new GhostscriptWrapper();
            bool convertResult = m_GhostscriptWrapper.Init(parameters.ToArray());

            Cleanup();

            return(convertResult);
        }