public void ExtractGhostscriptErrors_WithJustHeader_ReturnEmptyString() { string output = "GPL Ghostscript 9.10 (2013-08-30)"; output += "\nCopyright (C) 2013 Artifex Software, Inc. All rights reserved."; output += "\nThis software comes with NO WARRANTY: see the file PUBLIC for details."; var result = GhostscriptJob.ExtractGhostscriptErrors(output); Assert.AreEqual("", result); }
public void ExtractGhostscriptErrors_WithHeaderAndError_ReturnsError() { string output = "GPL Ghostscript 9.10 (2013-08-30)"; output += "\nCopyright (C) 2013 Artifex Software, Inc. All rights reserved."; output += "\nThis software comes with NO WARRANTY: see the file PUBLIC for details."; output += "\nError: /undefinedfilename in XYZ"; var result = GhostscriptJob.ExtractGhostscriptErrors(output); Assert.AreEqual("Error: /undefinedfilename in XYZ\r\n", result); }
public void ExtractGhostscriptErrors_WithHeaderAndLoadingFonts_ReturnEmptyString() { string output = "GPL Ghostscript 9.10 (2013-08-30)"; output += "\nCopyright (C) 2013 Artifex Software, Inc. All rights reserved."; output += "\nThis software comes with NO WARRANTY: see the file PUBLIC for details."; output += "\nLoading NimbusMonL-Regu font from %rom%Resource/Font/NimbusMonL-Regu... 3678736 2125723 1801368 456346 1 done."; var result = GhostscriptJob.ExtractGhostscriptErrors(output); Assert.AreEqual("", result); }
/// <summary> /// Creates the job from the queue by index /// </summary> /// <param name="id">Index of the jobinfo in the queue</param> /// <returns>The corresponding ComJob</returns> private PrintJob JobById(int id) { try { IJobInfo currentJobInfo = _comJobInfoQueue.JobInfos[id]; var jobTranslations = new JobTranslations(); jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(); IJob currentJob = new GhostscriptJob(currentJobInfo, SettingsHelper.GetDefaultProfile(), JobInfoQueue.Instance, jobTranslations); COMLogger.Trace("COM: Creating the ComJob from the queue determined by the index."); var indexedJob = new PrintJob(currentJob, _comJobInfoQueue); return(indexedJob); } catch (ArgumentOutOfRangeException) { throw new COMException("Invalid index. Please check the index parameter."); } }
/// <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(); }
private void SendTestMailButton_OnClick(object sender, RoutedEventArgs e) { var smtpMailAction = new SmtpMailAction(MailSignatureHelper.ComposeMailSignature(CurrentProfile.EmailSmtp)); var currentProfile = ((ActionsTabViewModel)DataContext).CurrentProfile.Copy(); #region check profile var result = smtpMailAction.Check(currentProfile); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); return; } #endregion #region create job string tempFolder = Path.GetTempPath(); string tmpTestFolder = Path.Combine(tempFolder, "PdfCreatorTest\\SendSmtpTestmail"); Directory.CreateDirectory(tmpTestFolder); string tmpInfFile = Path.Combine(tmpTestFolder, "SmtpTest.inf"); var sb = new StringBuilder(); sb.AppendLine("[1]"); sb.AppendLine("SessionId=1"); sb.AppendLine("WinStation=Console"); sb.AppendLine("UserName=SampleUser1234"); sb.AppendLine("ClientComputer=\\PC1"); sb.AppendLine("PrinterName=PDFCreator"); sb.AppendLine("JobId=1"); sb.AppendLine("DocumentTitle=SmtpTest"); sb.AppendLine(""); File.WriteAllText(tmpInfFile, sb.ToString(), Encoding.GetEncoding("Unicode")); JobTranslations jobTranslations = new JobTranslations(); jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(true); var tempFolderProvider = new StaticTempFolderProvider(Path.Combine(Path.GetTempPath(), "PDFCreator")); var job = new GhostscriptJob(new JobInfo(tmpInfFile), new ConversionProfile(), tempFolderProvider, jobTranslations); job.Profile = currentProfile; #endregion #region add password if (string.IsNullOrEmpty(Password)) { var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.None, currentProfile.EmailSmtp.Address, currentProfile.EmailSmtp.Recipients); if (pwWindow.ShowDialogTopMost() != SmtpPasswordResponse.OK) { Directory.Delete(tmpTestFolder, true); return; } job.Passwords.SmtpPassword = pwWindow.SmtpPassword; } else { job.Passwords.SmtpPassword = Password; } #endregion #region add testfile string testFile = (Path.Combine(tmpTestFolder, "testfile.txt")); File.WriteAllText(testFile, @"PDFCreator", Encoding.GetEncoding("Unicode")); job.OutputFiles.Add(testFile); #endregion LogManager.GetCurrentClassLogger().Info("Send test mail over smtp."); result = smtpMailAction.ProcessJob(job); Directory.Delete(tmpTestFolder, true); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); } else { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = TranslationHelper.Instance.TranslatorInstance.GetFormattedTranslation("SmtpEmailActionSettings", "TestMailSent", "Test mail sent to {0}.", job.Profile.EmailSmtp.Recipients); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Info); } }