Exemple #1
0
        private int num_pages = -1;        // signal: -3 and below: failed permanently (2 + attempts to diagnose); -2: failed permanently due to absent PDF file; -1: not yet determined; 0: empty document (rare/weird!); > 0: number of actual pages in document

        /// <summary>
        /// This is an approximate response: it takes a *fast* shortcut to check if the given
        /// PDF has been OCR'd in the past.
        ///
        /// The emphasis here is on NOT triggering a new OCR action! Just taking a peek, *quickly*.
        ///
        /// The cost: one(1) I/O per check.
        ///
        /// Implementation Note: do NOT check if DocumentExists: our pagecount cache check is sufficient and one I/O per check.
        /// </summary>
        public bool HasOCRdata()
        {
            // BasePath:
            string base_path = ConfigurationManager.Instance.ConfigurationRecord.System_OverrideDirectoryForOCRs;

            if (String.IsNullOrEmpty(base_path))
            {
                base_path = BASE_PATH_DEFAULT;
            }
            // string cached_count_filename = MakeFilename_PageCount(Fingerprint);
            // return MakeFilenameWith2LevelIndirection("pagecount", "0", "txt");
            string indirection_characters = Fingerprint.Substring(0, 2).ToUpper();
            string cached_count_filename  = Path.GetFullPath(Path.Combine(base_path, indirection_characters, String.Format("{0}.{1}.{2}.{3}", Fingerprint, @"pagecount", @"0", @"txt")));

            return(File.Exists(cached_count_filename));
        }
Exemple #2
0
        private string MakeFilenameWith2LevelIndirection(string file_type, object token, string extension)
        {
            string indirection_characters = Fingerprint.Substring(0, 2).ToUpper();

            return(Path.GetFullPath(Path.Combine(BasePath, indirection_characters, String.Format("{0}.{1}.{2}.{3}", Fingerprint, file_type, token, extension))));
        }