コード例 #1
0
        private void OutputBatch(OutputFormat batchOutput, IEnumerable <BaseExportData> batchData, int batchCounter, string identifier, string catalogName = null)
        {
            var data    = batchData.ToList();
            var message = string.Format("Starting batch {0} {1} for identifier {2} containing {3} records.", batchOutput.ToString(), batchCounter, identifier, data.Count);

            if (batchCounter == 1)
            {
                _logger.InfoFormat(message);
            }
            else
            {
                _logger.DebugFormat(message);
            }

            var instruction = new OutputInstruction
            {
                Format         = batchOutput,
                CatalogName    = catalogName,
                Count          = batchCounter,
                OutputLocation = identifier,
                OutputName     = string.Format("{0}_{1}", batchOutput.ToString(), batchCounter),
                Data           = data
            };

            RecordOutput(instruction);
            _logger.DebugFormat("Completed batch {0}.", batchOutput.ToString());
        }
コード例 #2
0
        /// <summary>
        ///     Generates a job with default testpasswords (if required by the profile settings).
        ///     Therefore an INF file and the required PS Files will be created and set in the jobs JobInfo.
        /// </summary>
        /// <param name="psFiles">select test content according to psFiles</param>
        /// <param name="outputformat">set output format</param>
        public void GenerateGsJob(PSfiles psFiles, OutputFormat outputformat)
        {
            _profile.OutputFormat = outputformat;

            GenerateInfFileWithPsFiles(psFiles);
            var jobInfoReader = new JobInfoManager(new LocalTitleReplacerProvider(new List <TitleReplacement>()));

            JobInfo = jobInfoReader.ReadFromInfFile(TmpInfFile);

            var jobTranslations = new JobTranslations();

            jobTranslations.EmailSignature = "\r\n\r\nCreated with PDFCreator";

            Job = new Job(JobInfo, _profile, jobTranslations, AppSettings.Accounts);

            var extension = outputformat.ToString();

            if (outputformat == OutputFormat.PdfA1B || outputformat == OutputFormat.PdfA2B || outputformat == OutputFormat.PdfX)
            {
                extension = "pdf";
            }
            Job.OutputFilenameTemplate         = TmpInfFile.Replace(".inf", "." + extension);
            Job.Passwords.PdfUserPassword      = _profile.PdfSettings.Security.RequireUserPassword ? UserPassword : null;
            Job.Passwords.PdfOwnerPassword     = _profile.PdfSettings.Security.Enabled ? OwnerPassword : null;
            Job.Passwords.PdfSignaturePassword = _profile.PdfSettings.Signature.Enabled ? SignaturePassword : null;

            EnableLogging();
            InitMissingData();
        }
コード例 #3
0
ファイル: ConversionProfile.cs プロジェクト: u001tag/clawPDF
 public void StoreValues(Data data, string path)
 {
     AttachmentPage.StoreValues(data, path + @"AttachmentPage\");
     AutoSave.StoreValues(data, path + @"AutoSave\");
     BackgroundPage.StoreValues(data, path + @"BackgroundPage\");
     CoverPage.StoreValues(data, path + @"CoverPage\");
     EmailClient.StoreValues(data, path + @"EmailClient\");
     EmailSmtp.StoreValues(data, path + @"EmailSmtp\");
     Ftp.StoreValues(data, path + @"Ftp\");
     Ghostscript.StoreValues(data, path + @"Ghostscript\");
     JpegSettings.StoreValues(data, path + @"JpegSettings\");
     PdfSettings.StoreValues(data, path + @"PdfSettings\");
     PngSettings.StoreValues(data, path + @"PngSettings\");
     Printing.StoreValues(data, path + @"Printing\");
     Properties.StoreValues(data, path + @"Properties\");
     SaveDialog.StoreValues(data, path + @"SaveDialog\");
     Scripting.StoreValues(data, path + @"Scripting\");
     Stamping.StoreValues(data, path + @"Stamping\");
     TiffSettings.StoreValues(data, path + @"TiffSettings\");
     data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate));
     data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate));
     data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid));
     data.SetValue(@"" + path + @"Name", Data.EscapeString(Name));
     data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString());
     data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString());
     data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString());
     data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString());
     data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate));
 }
コード例 #4
0
ファイル: OutputDevice.cs プロジェクト: masums/clawPDF
        public string[] GetValidExtensions(OutputFormat format)
        {
            string[] validExtensions;

            switch (format)
            {
            case OutputFormat.Jpeg:
                validExtensions = new[] { ".jpg", ".jpeg" };
                break;

            case OutputFormat.Tif:
                validExtensions = new[] { ".tif", ".tiff" };
                break;

            case OutputFormat.Pdf:
            case OutputFormat.PdfA1B:
            case OutputFormat.PdfA2B:
            case OutputFormat.PdfX:
                validExtensions = new[] { ".pdf" };
                break;

            case OutputFormat.Txt:
                validExtensions = new[] { ".txt" };
                break;


            default:
                validExtensions = new[] { "." + format.ToString().ToLowerInvariant() };
                break;
            }

            return(validExtensions);
        }
コード例 #5
0
ファイル: DefaultViewer.cs プロジェクト: sm2x/PDFCreator
 public void StoreValues(Data data, string path)
 {
     data.SetValue(@"" + path + @"IsActive", IsActive.ToString());
     data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString());
     data.SetValue(@"" + path + @"Parameters", Data.EscapeString(Parameters));
     data.SetValue(@"" + path + @"Path", Data.EscapeString(Path));
 }
コード例 #6
0
        public string DoWork(string inputFile, OutputFormat outputFormat)
        {
            Process process      = new Process();
            string  readerOutput = "";


            process.StartInfo.Arguments              = _arguments.GetValue(outputFormat.ToString()) + inputFile;
            process.StartInfo.FileName               = _programmPath;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;


            process.Start();

            using (StreamReader reader = process.StandardOutput)
            {
                readerOutput = reader.ReadToEnd();
            }


            process.WaitForExit();

            return(readerOutput);
        }
コード例 #7
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("[AttachmentPage]");
            sb.AppendLine(AttachmentPage.ToString());
            sb.AppendLine("[AutoSave]");
            sb.AppendLine(AutoSave.ToString());
            sb.AppendLine("[BackgroundPage]");
            sb.AppendLine(BackgroundPage.ToString());
            sb.AppendLine("[CoverPage]");
            sb.AppendLine(CoverPage.ToString());
            sb.AppendLine("[DropboxSettings]");
            sb.AppendLine(DropboxSettings.ToString());
            sb.AppendLine("[EmailClientSettings]");
            sb.AppendLine(EmailClientSettings.ToString());
            sb.AppendLine("[EmailSmtpSettings]");
            sb.AppendLine(EmailSmtpSettings.ToString());
            sb.AppendLine("[Ftp]");
            sb.AppendLine(Ftp.ToString());
            sb.AppendLine("[Ghostscript]");
            sb.AppendLine(Ghostscript.ToString());
            sb.AppendLine("[JpegSettings]");
            sb.AppendLine(JpegSettings.ToString());
            sb.AppendLine("[PdfSettings]");
            sb.AppendLine(PdfSettings.ToString());
            sb.AppendLine("[PngSettings]");
            sb.AppendLine(PngSettings.ToString());
            sb.AppendLine("[Printing]");
            sb.AppendLine(Printing.ToString());
            sb.AppendLine("[Properties]");
            sb.AppendLine(Properties.ToString());
            sb.AppendLine("[SaveDialog]");
            sb.AppendLine(SaveDialog.ToString());
            sb.AppendLine("[Scripting]");
            sb.AppendLine(Scripting.ToString());
            sb.AppendLine("[Stamping]");
            sb.AppendLine(Stamping.ToString());
            sb.AppendLine("[TextSettings]");
            sb.AppendLine(TextSettings.ToString());
            sb.AppendLine("[TiffSettings]");
            sb.AppendLine(TiffSettings.ToString());
            sb.AppendLine("[UserTokens]");
            sb.AppendLine(UserTokens.ToString());
            sb.AppendLine("AuthorTemplate=" + AuthorTemplate.ToString());
            sb.AppendLine("FileNameTemplate=" + FileNameTemplate.ToString());
            sb.AppendLine("Guid=" + Guid.ToString());
            sb.AppendLine("KeywordTemplate=" + KeywordTemplate.ToString());
            sb.AppendLine("Name=" + Name.ToString());
            sb.AppendLine("OpenViewer=" + OpenViewer.ToString());
            sb.AppendLine("OpenWithPdfArchitect=" + OpenWithPdfArchitect.ToString());
            sb.AppendLine("OutputFormat=" + OutputFormat.ToString());
            sb.AppendLine("ShowProgress=" + ShowProgress.ToString());
            sb.AppendLine("SkipPrintDialog=" + SkipPrintDialog.ToString());
            sb.AppendLine("SubjectTemplate=" + SubjectTemplate.ToString());
            sb.AppendLine("TitleTemplate=" + TitleTemplate.ToString());

            return(sb.ToString());
        }
コード例 #8
0
 static string GetExtension(OutputFormat outputFormat)
 {
     if (outputFormat == OutputFormat.Original)
     {
         return(".dat");
     }
     return(string.Format(".{0}", outputFormat.ToString().ToLower()));
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: ToshchevIvan/di
        private static ImageFormat GetImageFormat(OutputFormat format)
        {
            const BindingFlags flags = BindingFlags.GetProperty;
            var type = typeof(ImageFormat);
            var o    = type.InvokeMember(format.ToString(), flags, null, type, null);

            return((ImageFormat)o);
        }
コード例 #10
0
        public static string GetDescription(this OutputFormat format)
        {
            var type        = typeof(OutputFormat);
            var memInfo     = type.GetMember(format.ToString());
            var attributes  = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
            var description = ((DescriptionAttribute)attributes[0]).Description;

            return(description);
        }
コード例 #11
0
        private void OutputBatch(OutputFormat batchOutput, IEnumerable <BaseExportData> batchData, int batchCounter, string identifier, string catalogName = null)
        {
            var data = batchData.ToList();

            LogStartBatch(batchOutput, batchCounter, identifier, data.Count);

            var instruction = new OutputInstruction
            {
                Format         = batchOutput,
                CatalogName    = catalogName,
                Count          = batchCounter,
                OutputLocation = OutputFolderPath,
                OutputName     = batchOutput.ToString() + identifier + batchCounter,
                Data           = data
            };

            _outputInstructionProcessor.RecordOutput(instruction);
            Log.DebugFormat("Completed batch {0}{1}{2}.", batchOutput.ToString(), identifier, batchCounter);
        }
コード例 #12
0
ファイル: DefaultViewer.cs プロジェクト: sm2x/PDFCreator
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("IsActive=" + IsActive.ToString());
            sb.AppendLine("OutputFormat=" + OutputFormat.ToString());
            sb.AppendLine("Parameters=" + Parameters.ToString());
            sb.AppendLine("Path=" + Path.ToString());

            return(sb.ToString());
        }
コード例 #13
0
        private string GetExtension(OutputFormat outputFormat)
        {
            var formatString = outputFormat.ToString().ToLowerInvariant();

            if (formatString.StartsWith("pdf"))
            {
                return("pdf");
            }

            return(formatString);
        }
コード例 #14
0
ファイル: Conversion.cs プロジェクト: Dryadepy/Xabe.FFmpeg
 private string BuildOutputFormat()
 {
     if (OutputFormat != null)
     {
         return($"-f {OutputFormat.ToString()} ");
     }
     else
     {
         return(string.Empty);
     }
 }
コード例 #15
0
        public static List <string> Convert(string filename, string img_filename, OutputFormat output_format, int resolution = 300)
        {
            string        error  = null;
            List <string> errors = new List <string>();
            String        gsPath = GetProgramFilePath("gsdll32.dll", out error);

            if (!System.IO.File.Exists(gsPath))
            {
                File.WriteAllBytes(gsPath, Properties.Resources.gsdll32);
            }
            if (error != null)
            {
                errors.Add(error);
            }

            if (File.Exists(img_filename))
            {
                File.Delete(img_filename);
            }

            //This is the object that perform the real conversion!
            PDFConvert converter = new PDFConvert();

            //Ok now check what version is!
            GhostScriptRevision version = converter.GetRevision();

            //lblVersion.Text = version.intRevision.ToString() + " " + version.intRevisionDate;
            bool Converted = false;

            //Setup the converter
            converter.RenderingThreads = -1;
            converter.TextAlphaBit     = -1;
            converter.TextAlphaBit     = -1;

            converter.FitPage      = true;
            converter.JPEGQuality  = mPrintQuality; //80
            converter.OutputFormat = output_format.ToString();

            converter.OutputToMultipleFile = false;
            converter.FirstPageToConvert   = -1;
            converter.LastPageToConvert    = -1;

            converter.ResolutionX = converter.ResolutionY = resolution;

            System.IO.FileInfo input = new FileInfo(filename);
            if (!string.IsNullOrEmpty(mGSPath))
            {
                converter.GSPath = mGSPath;
            }
            Converted = converter.Convert(input.FullName, img_filename);

            return(errors);
        }
コード例 #16
0
        /// <summary>
        /// Allows to set the internal OutputFormat of the GraphCommand thus allowing you to
        /// retrieve GRAPHJSON or GraphsonCompact (without references to Edges) as result from Traversals
        /// </summary>
        /// <param name="cmd"></param>
        /// <param name="format"></param>
        public static void SetOutputFormat(this GraphCommand cmd, OutputFormat format)
        {
            Type         graphCommandType         = typeof(GraphCommand);
            PropertyInfo outputFormatPropertyInfo = graphCommandType.GetProperty("OutputFormat", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            object       originalValue            = outputFormatPropertyInfo.GetValue(cmd);
            Type         outputFormatType         = originalValue.GetType();

            string[] eNames       = outputFormatType.GetEnumNames();
            object   desiredValue = Enum.Parse(outputFormatType, format.ToString());

            outputFormatPropertyInfo.SetValue(cmd, desiredValue);
        }
コード例 #17
0
 /// <summary>
 /// Prepares arguments for capturing executable
 /// </summary>
 string GetArguments(string url, string filename)
 {
     return("--url={0} --out={1} --out-format={2}{3}{4}{5}{6}".FormatWith(
                url,
                filename,
                OutputFormat.ToString().ToLower(),
                " --min-width={0}".FormatWith(MinWidth).OnlyWhen(MinWidth > 0),
                " --min-height={0}".FormatWith(MinHeight).OnlyWhen(MinHeight > 0),
                " --delay={0}".FormatWith(Delay).OnlyWhen(Delay > 0),
                " --javascript={0}".FormatWith(Javascript ? "on" : "off")
                ));
 }
コード例 #18
0
ファイル: BaseWriter.cs プロジェクト: danogwok/DirLister
        /// <summary>
        /// Replace path and space characters in filename with underscores
        /// </summary>
        private string ReplacePathCharacters(OutputFormat format)
        {
            var chars    = Path.GetInvalidFileNameChars();
            var filename = chars
                           .Aggregate(Configuration.InputFolders[0], (current, c) => current.Replace(c, '_'));

            filename = filename.Replace(' ', '_')
                       .Replace("__", "_")
                       .Trim('_');

            return($"{filename}.{format.ToString().ToLowerInvariant()}");
        }
コード例 #19
0
ファイル: WikiOutput.cs プロジェクト: nuxleus/flexwiki
    public static WikiOutput ForFormat(OutputFormat aFormat, WikiOutput parent)
    {
      switch (aFormat)
      {
        case OutputFormat.HTML:
          return new HTMLWikiOutput(parent);

        case OutputFormat.Testing:
          return new TestWikiOutput(parent);

        default:
          throw new Exception("Unsupported output type requested: " + aFormat.ToString());
      }
    }
コード例 #20
0
 public void StoreValues(Data data, string path)
 {
     AttachmentPage.StoreValues(data, path + @"AttachmentPage\");
     AutoSave.StoreValues(data, path + @"AutoSave\");
     BackgroundPage.StoreValues(data, path + @"BackgroundPage\");
     CoverPage.StoreValues(data, path + @"CoverPage\");
     CustomScript.StoreValues(data, path + @"CustomScript\");
     DropboxSettings.StoreValues(data, path + @"DropboxSettings\");
     EmailClientSettings.StoreValues(data, path + @"EmailClientSettings\");
     EmailSmtpSettings.StoreValues(data, path + @"EmailSmtpSettings\");
     ForwardToFurtherProfile.StoreValues(data, path + @"ForwardToFurtherProfile\");
     Ftp.StoreValues(data, path + @"Ftp\");
     Ghostscript.StoreValues(data, path + @"Ghostscript\");
     HttpSettings.StoreValues(data, path + @"HttpSettings\");
     JpegSettings.StoreValues(data, path + @"JpegSettings\");
     PdfSettings.StoreValues(data, path + @"PdfSettings\");
     PngSettings.StoreValues(data, path + @"PngSettings\");
     Printing.StoreValues(data, path + @"Printing\");
     Properties.StoreValues(data, path + @"Properties\");
     Scripting.StoreValues(data, path + @"Scripting\");
     Stamping.StoreValues(data, path + @"Stamping\");
     TextSettings.StoreValues(data, path + @"TextSettings\");
     TiffSettings.StoreValues(data, path + @"TiffSettings\");
     UserTokens.StoreValues(data, path + @"UserTokens\");
     Watermark.StoreValues(data, path + @"Watermark\");
     for (int i = 0; i < ActionOrder.Count; i++)
     {
         data.SetValue(path + @"ActionOrder\" + i + @"\ActionOrder", Data.EscapeString(ActionOrder[i]));
     }
     data.SetValue(path + @"ActionOrder\numClasses", ActionOrder.Count.ToString());
     data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate));
     data.SetValue(@"" + path + @"EnableWorkflowEditor", EnableWorkflowEditor.ToString());
     data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate));
     data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid));
     data.SetValue(@"" + path + @"KeywordTemplate", Data.EscapeString(KeywordTemplate));
     data.SetValue(@"" + path + @"Name", Data.EscapeString(Name));
     data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString());
     data.SetValue(@"" + path + @"OpenWithPdfArchitect", OpenWithPdfArchitect.ToString());
     data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString());
     data.SetValue(@"" + path + @"SaveFileTemporary", SaveFileTemporary.ToString());
     data.SetValue(@"" + path + @"ShowAllNotifications", ShowAllNotifications.ToString());
     data.SetValue(@"" + path + @"ShowOnlyErrorNotifications", ShowOnlyErrorNotifications.ToString());
     data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString());
     data.SetValue(@"" + path + @"ShowQuickActions", ShowQuickActions.ToString());
     data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString());
     data.SetValue(@"" + path + @"SubjectTemplate", Data.EscapeString(SubjectTemplate));
     data.SetValue(@"" + path + @"TargetDirectory", Data.EscapeString(TargetDirectory));
     data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate));
 }
コード例 #21
0
        public void Execute(CommandExecutionContext context)
        {
            AppDomainSetup setupInfo = new AppDomainSetup();

            setupInfo.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
            setupInfo.PrivateBinPath  = "bin";
            AppDomain appDomain = AppDomain.CreateDomain("RunQueryAppDomain", null, setupInfo);

            string compilationOutputDirectory = null;

            object[] arguments;
            if (context.ProcessId != 0)
            {
                arguments = new object[] { context.ProcessId, context.DacLocation, context.Printer };
            }
            else
            {
                arguments = new object[] { context.DumpFile, context.DacLocation, context.Printer };
            }
            using (RunInSeparateAppDomain runner = (RunInSeparateAppDomain)appDomain.CreateInstanceAndUnwrap(
                       typeof(RunInSeparateAppDomain).Assembly.FullName,
                       typeof(RunInSeparateAppDomain).FullName,
                       false, System.Reflection.BindingFlags.CreateInstance, null,
                       arguments, null, null
                       )
                   )
            {
                try
                {
                    compilationOutputDirectory = runner.RunQuery(
                        OutputFormat.ToString(),
                        Query,
                        context.Defines);
                }
                catch (Exception ex)
                {
                    // Catching everything here because the input is user-controlled, so we can have
                    // compilation errors, dynamic binder errors, and a variety of other things I haven't
                    // even thought of yet.
                    context.WriteError(ex.Message);
                }
            }

            AppDomain.Unload(appDomain);
            if (compilationOutputDirectory != null)
            {
                Directory.Delete(compilationOutputDirectory, recursive: true);
            }
        }
コード例 #22
0
        private Tuple <int, string> GetPdfAConformance(OutputFormat outputFormat)
        {
            if (!outputFormat.ToString().ToUpper().StartsWith("PDFA"))
            {
                return(null);
            }

            switch (outputFormat)
            {
            case OutputFormat.PdfA1B: return(Tuple.Create(1, "B"));

            case OutputFormat.PdfA2B: return(Tuple.Create(2, "B"));

            default: throw new NotImplementedException($"Determining conformance for {outputFormat} was not implemented");
            }
        }
コード例 #23
0
        public void RetypeFileName_FileTypeFilter_OnlyHasCurrentFormat(OutputFormat outputFormat)
        {
            SaveFileInteraction saveFileInteraction = null;

            HandleSaveFileInteraction(interaction =>
            {
                saveFileInteraction = interaction;
            });

            var query = BuildFileNameQuery();

            query.RetypeFileNameQuery(_someFile, outputFormat, RetypeReason.CopyError);

            // Filter has the Format "Title|filter|Title2|filter2" => we only expect one pipe for a single entry
            Assert.AreEqual(2, saveFileInteraction.Filter.Split('|').Length);
            Assert.IsTrue(saveFileInteraction.Filter.Contains(outputFormat.ToString().ToLower()));
        }
コード例 #24
0
        /// <summary>
        /// Helper method to create a temp image file
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public static string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors)
        {
            string tmpFile = Path.GetRandomFileName() + "." + outputFormat.ToString();

            // Prevent problems with "other characters", which could cause problems
            tmpFile = Regex.Replace(tmpFile, @"[^\d\w\.]", "");
            string tmpPath = Path.Combine(Path.GetTempPath(), tmpFile);

            LOG.Debug("Creating TMP File : " + tmpPath);

            try {
                ImageOutput.Save(image, tmpPath, true, quality, reduceColors, false);
                tmpFileCache.Add(tmpPath, tmpPath);
            } catch (Exception) {
                return(null);
            }
            return(tmpPath);
        }
コード例 #25
0
        public static string GetFileExtensionsForFormat(OutputFormat outputFormat)
        {
            switch (outputFormat)
            {
            case OutputFormat.Mp3:
            case OutputFormat.Wav:
            case OutputFormat.Flac:
            case OutputFormat.Mp4:
            case OutputFormat.Webm:
                return(outputFormat.ToString().ToLower());

            case OutputFormat.Vorbis:
                return("ogg");

            default:
                throw new ArgumentOutOfRangeException(nameof(outputFormat), outputFormat, null);
            }
        }
コード例 #26
0
		public Translation Translate(string text, LangPair lang, OutputFormat? format = null, bool options = false)
		{
			RestRequest request = new RestRequest("translate");
			request.AddParameter("key", _key);
			request.AddParameter("text", text);
			if (lang.OutputLang != Lang.None)
			{
				if (lang.InputLang == Lang.None)
					request.AddParameter("lang", lang.OutputLang.ToString().ToLowerInvariant());
				else
					request.AddParameter("lang", lang.ToString().ToLowerInvariant());
			}
			if (format.HasValue)
				request.AddParameter("format", format.ToString().ToLowerInvariant());
			if (options)
				request.AddParameter("options", "1");

			return SendRequest<Translation>(request);
		}
コード例 #27
0
        public static string FileExtension(this OutputFormat format)
        {
            switch (format)
            {
            case OutputFormat.Console:
                return(string.Empty);

            case OutputFormat.MarkDown:
                return("md");

            case OutputFormat.JSON:
            case OutputFormat.XML:
            case OutputFormat.Html:
                return(format.ToString().ToLowerInvariant());

            default:
                throw new NotImplementedException($"Format {format} has no default file extension");
            }
        }
コード例 #28
0
 public void StoreValues(Data data, string path)
 {
     AttachmentPage.StoreValues(data, path + @"AttachmentPage\");
     AutoSave.StoreValues(data, path + @"AutoSave\");
     BackgroundPage.StoreValues(data, path + @"BackgroundPage\");
     CoverPage.StoreValues(data, path + @"CoverPage\");
     CustomScript.StoreValues(data, path + @"CustomScript\");
     DropboxSettings.StoreValues(data, path + @"DropboxSettings\");
     EmailClientSettings.StoreValues(data, path + @"EmailClientSettings\");
     EmailSmtpSettings.StoreValues(data, path + @"EmailSmtpSettings\");
     Ftp.StoreValues(data, path + @"Ftp\");
     Ghostscript.StoreValues(data, path + @"Ghostscript\");
     HttpSettings.StoreValues(data, path + @"HttpSettings\");
     JpegSettings.StoreValues(data, path + @"JpegSettings\");
     PdfSettings.StoreValues(data, path + @"PdfSettings\");
     PngSettings.StoreValues(data, path + @"PngSettings\");
     Printing.StoreValues(data, path + @"Printing\");
     Properties.StoreValues(data, path + @"Properties\");
     Scripting.StoreValues(data, path + @"Scripting\");
     Stamping.StoreValues(data, path + @"Stamping\");
     TextSettings.StoreValues(data, path + @"TextSettings\");
     TiffSettings.StoreValues(data, path + @"TiffSettings\");
     UserTokens.StoreValues(data, path + @"UserTokens\");
     data.SetValue(@"" + path + @"AuthorTemplate", Data.EscapeString(AuthorTemplate));
     data.SetValue(@"" + path + @"FileNameTemplate", Data.EscapeString(FileNameTemplate));
     data.SetValue(@"" + path + @"Guid", Data.EscapeString(Guid));
     data.SetValue(@"" + path + @"KeywordTemplate", Data.EscapeString(KeywordTemplate));
     data.SetValue(@"" + path + @"Name", Data.EscapeString(Name));
     data.SetValue(@"" + path + @"OpenViewer", OpenViewer.ToString());
     data.SetValue(@"" + path + @"OpenWithPdfArchitect", OpenWithPdfArchitect.ToString());
     data.SetValue(@"" + path + @"OutputFormat", OutputFormat.ToString());
     data.SetValue(@"" + path + @"ShowAllNotifications", ShowAllNotifications.ToString());
     data.SetValue(@"" + path + @"ShowOnlyErrorNotifications", ShowOnlyErrorNotifications.ToString());
     data.SetValue(@"" + path + @"ShowProgress", ShowProgress.ToString());
     data.SetValue(@"" + path + @"ShowQuickActions", ShowQuickActions.ToString());
     data.SetValue(@"" + path + @"SkipPrintDialog", SkipPrintDialog.ToString());
     data.SetValue(@"" + path + @"SubjectTemplate", Data.EscapeString(SubjectTemplate));
     data.SetValue(@"" + path + @"TargetDirectory", Data.EscapeString(TargetDirectory));
     data.SetValue(@"" + path + @"TitleTemplate", Data.EscapeString(TitleTemplate));
 }
コード例 #29
0
ファイル: TestHelper.cs プロジェクト: zsy960/PDFCreator
        /// <summary>
        /// Generates a job with default testpasswords (if required by the profile settings).
        /// Therefore an INF file and the required PS Files will be created and set in the jobs JobInfo.
        /// </summary>
        /// <param name="psFiles">select test content according to psFiles</param>
        public void GenerateGsJob(PSfiles psFiles, OutputFormat outputformat, IFile fileWrap, IDirectory directoryWrap, string jobTempFolder = null)
        {
            var tempFolderProvider = MockRepository.GenerateStub <ITempFolderProvider>();

            if (string.IsNullOrEmpty(jobTempFolder))
            {
                tempFolderProvider.Stub(x => x.TempFolder)
                .Return(Environment.ExpandEnvironmentVariables(@"%TMP%\PDFCreator\Temp"));
            }
            else
            {
                tempFolderProvider.Stub(x => x.TempFolder)
                .Return(Environment.ExpandEnvironmentVariables(jobTempFolder));
            }
            _profile.OutputFormat = outputformat;

            GenerateInfFileWithPsFiles(psFiles);
            JobInfo = new JobInfo(TmpInfFile, AppSettings.TitleReplacement);

            var jobTranslations = new JobTranslations();

            jobTranslations.EmailSignature = "\r\n\r\nCreated with PDFCreator";

            Job = new GhostscriptJob(JobInfo, _profile, jobTranslations, tempFolderProvider, fileWrap, directoryWrap);

            string extension = outputformat.ToString();

            if (outputformat == OutputFormat.PdfA1B || outputformat == OutputFormat.PdfA2B || outputformat == OutputFormat.PdfX)
            {
                extension = "pdf";
            }
            Job.OutputFilenameTemplate         = TmpInfFile.Replace(".inf", "." + extension);
            Job.Passwords.PdfUserPassword      = _profile.PdfSettings.Security.RequireUserPassword ? UserPassword : null;
            Job.Passwords.PdfOwnerPassword     = _profile.PdfSettings.Security.Enabled ? OwnerPassword : null;
            Job.Passwords.PdfSignaturePassword = _profile.PdfSettings.Signature.Enabled ? SignaturePassword : null;

            EnableLogging();
        }
コード例 #30
0
        public async Task <List <HLSFile> > SaveHLSBatch(string path, OutputFormat format, int parentVideoId)
        {
            try
            {
                using (var dbContext = new VideoInformationContext())
                {
                    var savedFiles = Directory
                                     .EnumerateFiles(path)
                                     .Where(file => file.Contains(format.ToString()) && (file.ToLower().EndsWith("ts") || file.ToLower().EndsWith("m3u8")))
                                     .ToList();


                    foreach (var file in savedFiles)
                    {
                        var extension = file.Substring(file.LastIndexOf('.'));
                        var hls       = new HLSFile
                        {
                            Filename          = Path.GetFileName(file),
                            FileDirectory     = Directory.GetParent(file).Name,
                            ParentVideoFileId = parentVideoId,
                            HLSType           = extension.Equals("m3u8") ? HLSType.Playlist : HLSType.PartialVideo
                        };

                        await dbContext.HLS.AddAsync(hls);
                    }

                    await dbContext.SaveChangesAsync();

                    return(new List <HLSFile>());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw new Exception("Internal server error");
            }
        }
コード例 #31
0
        private void SaveOptions()
        {
            if (String.IsNullOrEmpty(RegistryKeyToStoreOptions))
            {
                return;
            }

            try
            {
                RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\" + RegistryKeyToStoreOptions);

                key.SetValue("Default Device", _defaultDevice, RegistryValueKind.String);
                key.SetValue("Save To", _saveTo.ToString(), RegistryValueKind.String);
                key.SetValue("Output Folder", _outputFolder, RegistryValueKind.String);
                key.SetValue("File Naming Template", _fileNamingTemplate, RegistryValueKind.String);
                key.SetValue("Output Format", _outputFormat.ToString(), RegistryValueKind.String);
                key.SetValue("JPEG Quality", _jpegQuality, RegistryValueKind.DWord);
                key.SetValue("TIFF Compression", _tiffCompression.ToString(), RegistryValueKind.String);
            }
            catch (Exception e)
            {
                throw new ScanException("Failed to save options", e);
            }
        }
コード例 #32
0
        /// <summary>
        ///   Raises the <see cref = "E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name = "e">The <see cref = "T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                // Assign field values
                FontNameDropDownList.SelectedValue = FontName;
                CustomFontPathTextBox.Text         = CustomFontPath;
                FontSizeTextBox.Text = FontSize.ToString();
                foreach (var fontStyle in FontStyles.Where(fontStyle => fontStyle != FontStyle.Regular))
                {
                    FontStyleCheckBoxList.Items.FindByText(fontStyle.ToString()).Selected = true;
                }
                ForegroundColorPicker.Value = ForegroundColor;
                BackgroundColorPicker.Value = BackgroundColor;
                ShadowColorPicker.Value     = ShadowColor;
                HorizontalAlignmentDropDownList.SelectedValue = HorizontalAlignment.ToString();
                VerticalAlignmentDropDownList.SelectedValue   = VerticalAlignment.ToString();
                ImageHeightTextBox.Text               = ImageHeight.ToString();
                ImageWidthTextBox.Text                = ImageWidth.ToString();
                _dataExtractor.Value                  = BackgroundMediaId;
                BackgroundMediaChooser.Value          = _dataExtractor.Value.ToString();
                ImageFormatDropDownList.SelectedValue = OutputFormat.ToString();

                // Image Preview
                //var image = System.Drawing.Image.FromFile(IOHelper.MapPath(ImagePreviewUrl));
                ImagePreview.Height   = ImageHeight < 1 ? Unit.Empty : Unit.Pixel(ImageHeight);
                ImagePreview.Width    = ImageWidth < 1 ? Unit.Empty : Unit.Pixel(ImageWidth);
                ImagePreview.ImageUrl = ImagePreviewUrl;
            }
            catch (Exception exception)
            {
                SetErrorMessage(exception);
            }
        }
コード例 #33
0
 /// <summary>
 /// Sets the output format to use. By default, the original format (or the closest match) is used.
 /// </summary>
 /// <param name="format">The desired output format</param>
 public OutputExpression Format(OutputFormat format)
 {
     builder.SetParameter(OutputCommands.Format, format.ToString().ToLowerInvariant());
     return this;
 }
 internal static string OutputFormatToString(OutputFormat value)
 {
     // serge: boost 1.60 requires uppercase input
     return value.ToString();
 }
コード例 #35
0
        private string CreateSessionImpl(
			Template template,
			string billingRef,
			string answers,
			string[] markedVariables,
			InterviewFormat interviewFormat,
			OutputFormat outputFormat,
			Dictionary<string, string> settings,
			string theme,
			bool showDownloadLinks,
			bool uploadPackage)
        {
            if (!(template.Location is PackageTemplateLocation))
                throw new Exception("HotDocs Cloud Services requires the use of template packages. Please use a PackageTemplateLocation derivative.");
            PackageTemplateLocation packageTemplateLocation = (PackageTemplateLocation)template.Location;

            if (uploadPackage)
            {
                UploadPackage(packageTemplateLocation.PackageID, billingRef, packageTemplateLocation.GetPackageStream());
            }

            var timestamp = DateTime.UtcNow;

            string hmac = HMAC.CalculateHMAC(
                SigningKey,
                timestamp,
                SubscriberId,
                packageTemplateLocation.PackageID,
                billingRef,
                interviewFormat,
                outputFormat,
                settings); // Additional settings = null for this app

            StringBuilder urlBuilder = new StringBuilder(string.Format(
                "{0}/newsession/{1}/{2}?interviewformat={3}&outputformat={4}",
                EmbeddedEndpointAddress, SubscriberId, packageTemplateLocation.PackageID,
                interviewFormat.ToString(), outputFormat.ToString()));

            if (markedVariables != null && markedVariables.Length > 0)
            {
                urlBuilder.AppendFormat("&markedvariables={0}", string.Join(",", markedVariables));
            }

            if (!string.IsNullOrEmpty(theme))
            {
                urlBuilder.AppendFormat("&theme={0}", theme);
            }

            if (!string.IsNullOrEmpty(billingRef))
            {
                urlBuilder.AppendFormat("&billingref={0}", billingRef);
            }

            if (showDownloadLinks)
            {
                urlBuilder.Append("&showdownloadlinks=true");
            }

            if (settings != null)
            {
                foreach (KeyValuePair<string, string> kv in settings)
                {
                    urlBuilder.AppendFormat("&{0}={1}", kv.Key, kv.Value ?? "");
                }
            }

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlBuilder.ToString());
            request.Method = "POST";
            request.ContentType = "text/xml; charset=utf-8";
            request.Headers["x-hd-date"] = timestamp.ToString("r");
            request.Headers[HttpRequestHeader.Authorization] = hmac;
            byte[] data = null;
            if (answers != null)
            {
                data = Encoding.UTF8.GetBytes(answers);
            }
            request.ContentLength = data != null ? data.Length : 0;

            if (!string.IsNullOrEmpty(ProxyServerAddress))
            {
                request.Proxy = new WebProxy(ProxyServerAddress);
            }
            else
            {
                request.Proxy = null;
            }

            Stream stream = request.GetRequestStream();
            if (data != null)
            {
                stream.Write(data, 0, data.Length);
            }
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            return reader.ReadLine();
        }
コード例 #36
0
ファイル: FilenameHelper.cs プロジェクト: yuhongfang/ShareX
 public static string GetFilenameFromPattern(string pattern, OutputFormat imageFormat, ICaptureDetails captureDetails)
 {
     return FillPattern(pattern, captureDetails, true) + "." + imageFormat.ToString().ToLower();
 }
 private static string OutputFormatToString(OutputFormat value)
 {
     return value.ToString().ToLowerInvariant();
 }
コード例 #38
0
        /// <summary>
        /// Helper method to create a temp image file
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public static string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors)
        {
            string tmpFile = Path.GetRandomFileName() + "." + outputFormat.ToString();
            // Prevent problems with "other characters", which could cause problems
            tmpFile = Regex.Replace(tmpFile, @"[^\d\w\.]", "");
            string tmpPath = Path.Combine(Path.GetTempPath(), tmpFile);
            LOG.Debug("Creating TMP File : " + tmpPath);

            try {
                ImageOutput.Save(image, tmpPath, true, quality, reduceColors, false);
                tmpFileCache.Add(tmpPath, tmpPath);
            } catch (Exception) {
                return null;
            }
            return tmpPath;
        }
 private static string OutputFormatToString(OutputFormat value)
 {
     // serge: boost 1.60 requires uppercase input
     return value.ToString();    //.ToLowerInvariant();
 }