namespace FileFlows.Pdf.FlowElements; /// /// A flow element that tests if a PDF matches the specified text /// public class PdfMatchesText : Node { /// public override int Inputs => 1; /// public override int Outputs => 2; /// public override FlowElementType Type => FlowElementType.Logic; /// public override string Icon => "fas fa-file-pdf"; /// public override string HelpUrl => "https://fileflows.com/docs/plugins/pdf/pdf-matches-text"; /// public override string Group => "PDF"; /// /// Gets or sets the text to check for /// [Required] [TextVariable(1)] public string Text { get; set; } = null!; /// public override int Execute(NodeParameters args) { var fileResult = args.FileService.GetLocalPath(args.WorkingFile); if (fileResult.Failed(out var error)) return args.Fail("Failed to get local file: " + error); var file = fileResult.Value; var text = args.ReplaceVariables(Text); args.Logger?.ILog("Checking if PDF match text: " + text); var matchResult = args.PdfHelper.MatchesText(file, text); if(matchResult.Failed(out error)) return args.Fail("Failed to find match text: " + error); if (matchResult.Value == false) { args.Logger?.ILog("PDF does not match the text: " + text); return 2; } args.Logger?.ILog("PDF match the text: " + text); return 1; } }