Question

Je connais plusieurs bibliothèques / outils qui peuvent le faire, mais je veux savoir si cela est possible avec juste d'ouvrir le fichier en tant que fichier texte et la recherche d'un mot-clé.

Était-ce utile?

La solution

un coup d'oeil à ceci: http://www.freevbcode.com/ShowCode. asp? ID = 8153
Modifier : pas de travail, peut-être trop vieux
Trouvé ceci:

public static int GetNoOfPagesPDF(string FileName)
        {
            int result = 0;
            FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            StreamReader r = new StreamReader(fs);
            string pdfText = r.ReadToEnd();
            System.Text.RegularExpressions.Regex regx = new Regex(@"/Type\s*/Page[^s]");
            System.Text.RegularExpressions.MatchCollection matches = regx.Matches(pdfText);
            result = matches.Count;
            return result;
        }

Ps: testé! Il fonctionne. voir ici source

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top