Пример #1
0
        /// <summary>
        ///     Get the list of Ghostscript Parameters. This List contains of a basic set of parameters together with some
        ///     device-specific
        ///     parameters that will be added by the device implementation
        /// </summary>
        /// <param name="ghostscriptVersion"></param>
        /// <returns>A list of parameters that will be passed to Ghostscript</returns>
        public IList <string> GetGhostScriptParameters(GhostscriptVersion ghostscriptVersion)
        {
            IList <string> parameters = new List <string>();

            var outputFormatHelper = new OutputFormatHelper();

            parameters.Add("gs");
            parameters.Add("--permit-file-all=\"" + Job.JobTempFolder + "\\\"");
            parameters.Add("-I" + ghostscriptVersion.LibPaths);
            parameters.Add("-sFONTPATH=" + _osHelper.WindowsFontsFolder);

            parameters.Add("-dNOPAUSE");
            parameters.Add("-dBATCH");

            if (!outputFormatHelper.HasValidExtension(Job.OutputFileTemplate, Job.Profile.OutputFormat))
            {
                outputFormatHelper.EnsureValidExtension(Job.OutputFileTemplate, Job.Profile.OutputFormat);
            }

            AddOutputfileParameter(parameters);

            AddDeviceSpecificParameters(parameters);

            // Add user-defined parameters
            if (!string.IsNullOrEmpty(Job.Profile.Ghostscript.AdditionalGsParameters))
            {
                var args = _commandLineUtil.CommandLineToArgs(Job.Profile.Ghostscript.AdditionalGsParameters);
                foreach (var s in args)
                {
                    parameters.Add(s);
                }
            }

            //Dictonary-Parameters must be the last Parameters
            if (DistillerDictonaries.Count > 0)
            {
                parameters.Add("-c");
                foreach (var parameter in DistillerDictonaries)
                {
                    parameters.Add(parameter);
                }
            }

            //Don't add further paramters here, since the distiller-parameters should be the last!

            parameters.Add("-f");

            SetSourceFiles(parameters, Job);

            // Compose name of the pdfmark file based on the location and name of the inf file
            var pdfMarkFileName = PathSafe.Combine(Job.JobTempFolder, "metadata.mtd");

            CreatePdfMarksFile(pdfMarkFileName);

            // Add pdfmark file as input file to set metadata
            parameters.Add(pdfMarkFileName);

            return(parameters);
        }
Пример #2
0
 public static int GetRevision(ref GhostscriptVersion revision, int length)
 {
     if (_is64BitProcess)
     {
         return(GetRevision64(ref revision, length));
     }
     return(GetRevision32(ref revision, length));
 }
Пример #3
0
        public void SetUp()
        {
            _fileWrap = Substitute.For <IFile>();
            _fileWrap.Exists(Arg.Any <string>()).Returns(true);

            _outputDevice       = ParametersTestHelper.GenerateDevice(OutputFormat.Pdf, _fileWrap);
            _ghostscriptVersion = ParametersTestHelper.GhostscriptVersionDummie;
        }
        public void SetUp()
        {
            _printerStub = MockRepository.GenerateStub <PrinterWrapper>();

            var jobStub = ParametersTestHelper.GenerateJobStub(OutputFormat.Txt);

            jobStub.OutputFiles = new List <string>();
            jobStub.OutputFiles.Add(TestFileDummie);

            var fileStub = MockRepository.GenerateStub <IFile>();

            var osHelperStub = MockRepository.GenerateStub <IOsHelper>();

            osHelperStub.Stub(x => x.WindowsFontsFolder).Return(ParametersTestHelper.WindowsFontsFolderDummie);

            _printingDevice = new PrintingDevice(jobStub, _printerStub, fileStub, osHelperStub);
            _printingDevice.Job.OutputFiles.Add(TestFileDummie);

            _ghostscriptVersion = ParametersTestHelper.GhostscriptVersionDummie;
        }
Пример #5
0
 public void SetUp()
 {
     _txtDevice          = ParametersTestHelper.GenerateDevice(OutputFormat.Txt);
     _ghostscriptVersion = ParametersTestHelper.GhostscriptVersionDummie;
 }
Пример #6
0
 private static extern int GetRevision64(ref GhostscriptVersion revision, int length);
Пример #7
0
        /// <summary>
        ///     Get the list of Ghostscript Parameters. This List contains of a basic set of parameters together with some
        ///     device-specific
        ///     parameters that will be added by the device implementation
        /// </summary>
        /// <param name="ghostscriptVersion"></param>
        /// <returns>A list of parameters that will be passed to Ghostscript</returns>
        public IList <string> GetGhostScriptParameters(GhostscriptVersion ghostscriptVersion)
        {
            IList <string> parameters = new List <string>();

            parameters.Add("gs");
            parameters.Add("-sFONTPATH=" + OsHelper.WindowsFontsFolder);

            parameters.Add("-dNOPAUSE");
            parameters.Add("-dBATCH");

            if (!HasValidExtension(Job.OutputFilenameTemplate, Job.Profile.OutputFormat))
            {
                MakeValidExtension(Job.OutputFilenameTemplate, Job.Profile.OutputFormat);
            }

            AddOutputfileParameter(parameters);

            AddDeviceSpecificParameters(parameters);

            // Add user-defined parameters
            if (!string.IsNullOrEmpty(Job.Profile.Ghostscript.AdditionalGsParameters))
            {
                var args = FileUtil.Instance.CommandLineToArgs(Job.Profile.Ghostscript.AdditionalGsParameters);
                foreach (var s in args)
                {
                    parameters.Add(s);
                }
            }

            //Dictonary-Parameters must be the last Parameters
            if (DistillerDictonaries.Count > 0)
            {
                parameters.Add("-c");
                foreach (var parameter in DistillerDictonaries)
                {
                    parameters.Add(parameter);
                }
            }

            //Don't add further paramters here, since the distiller-parameters should be the last!

            parameters.Add("-f");

            if (Job.Profile.Stamping.Enabled)
            {
                // Compose name of the stamp file based on the location and name of the inf file
                var stampFileName = PathSafe.Combine(Job.JobTempFolder,
                                                     PathSafe.GetFileNameWithoutExtension(Job.JobInfo.InfFile) + ".stm");
                CreateStampFile(stampFileName, Job.Profile);
                parameters.Add(stampFileName);
            }

            if (Job.Profile.CoverPage.Enabled)
            {
                parameters.Add(Job.Profile.CoverPage.File);
            }

            foreach (var sfi in Job.JobInfo.SourceFiles)
            {
                parameters.Add(sfi.Filename);
            }

            if (Job.Profile.AttachmentPage.Enabled)
            {
                parameters.Add(Job.Profile.AttachmentPage.File);
            }

            //Compose name of the pdfmark file based on the location and name of the inf file
            var pdfMarkFileName = PathSafe.Combine(Job.JobTempFolder, "metadata.mtd");

            Directory.CreateDirectory(Job.JobTempFolder);
            Directory.CreateDirectory(Job.JobTempFolder + @"\tempoutput");
            CreatePdfMarksFile(pdfMarkFileName);

            // Add pdfmark file as input file to set metadata
            parameters.Add(pdfMarkFileName);

            return(parameters);
        }
Пример #8
0
 public GhostscriptConverter(GhostscriptVersion ghostscriptVersion)
 {
     _ghostscriptVersion = ghostscriptVersion;
 }
Пример #9
0
 private static extern int GetRevision64(ref GhostscriptVersion revision, int length);
Пример #10
0
 public static int GetRevision(ref GhostscriptVersion revision, int length)
 {
     if(_is64BitProcess)
     {
         return GetRevision64(ref revision, length);
     }
     return GetRevision32(ref revision, length);
 }
 public GhostscriptConverterFactory(IGhostscriptDiscovery ghostscriptDiscovery)
 {
     _ghostscriptVersion = ghostscriptDiscovery.GetGhostscriptInstance();
 }