namespace Pdftract; /// /// Options controlling PDF extraction behavior. /// public sealed class ExtractOptions { /// /// Password for encrypted PDFs. /// public string? Password { get; init; } /// /// ISO 639-3 language code for OCR. /// public string? OcrLanguage { get; init; } /// /// Confidence threshold for OCR (0-1). /// public double? OcrThreshold { get; init; } /// /// Preserve original reading order and layout. /// public bool? PreserveLayout { get; init; } /// /// Extract embedded images. /// public bool? ExtractImages { get; init; } /// /// Format for extracted images (png, jpg, webp). /// public string? ImageFormat { get; init; } /// /// Minimum dimension for image extraction. /// public int? MinImageSize { get; init; } /// /// Maximum seconds to wait for the operation. /// public int? Timeout { get; init; } internal List ToArgs() { var args = new List(); if (Password is not null) { args.Add("--password"); args.Add(Password); } if (OcrLanguage is not null) { args.Add("--ocr-language"); args.Add(OcrLanguage); } if (OcrThreshold.HasValue) { args.Add("--ocr-threshold"); args.Add(OcrThreshold.Value.ToStringInvariant()); } if (PreserveLayout == true) { args.Add("--preserve-layout"); } if (ExtractImages == true) { args.Add("--extract-images"); } if (ImageFormat is not null) { args.Add("--image-format"); args.Add(ImageFormat); } if (MinImageSize.HasValue) { args.Add("--min-image-size"); args.Add(MinImageSize.Value.ToString()); } if (Timeout.HasValue) { args.Add("--timeout"); args.Add(Timeout.Value.ToString()); } return args; } } /// /// Options controlling search behavior. /// public sealed class SearchOptions { /// /// Ignore case when matching. /// public bool? CaseInsensitive { get; init; } /// /// Treat pattern as regular expression. /// public bool? Regex { get; init; } /// /// Match only whole words. /// public bool? WholeWord { get; init; } /// /// Maximum matches to return. /// public int? MaxResults { get; init; } internal List ToArgs() { var args = new List(); if (CaseInsensitive == true) { args.Add("--case-insensitive"); } if (Regex == true) { args.Add("--regex"); } if (WholeWord == true) { args.Add("--whole-word"); } if (MaxResults.HasValue) { args.Add("--max-results"); args.Add(MaxResults.Value.ToString()); } return args; } } /// /// Options controlling hash computation behavior. /// public sealed class HashOptions { /// /// Password for encrypted PDFs. /// public string? Password { get; init; } internal List ToArgs() { var args = new List(); if (Password is not null) { args.Add("--password"); args.Add(Password); } return args; } } file static class DoubleExtensions { public static string ToStringInvariant(this double value) => value.ToString(System.Globalization.CultureInfo.InvariantCulture); }