Je souhaite vérifier un document PDF à l'aide de TestNG et PDFBox.
Je demanderais si PDF est capable de vérifier contient un texte comme celui-ci:
PDFParser parser = new PDFParser(stream);
parser.getDocument().conntains("ABC")
Réponses:
1 pour la réponse № 1Essayez ci-dessous le code: -
public void ReadPDF() throws Exception {
URL TestURL = new URL("http://www.axmag.com/download/pdfurl-guide.pdf");
BufferedInputStream TestFile = new BufferedInputStream(TestURL.openStream());
PDFParser TestPDF = new PDFParser(TestFile);
TestPDF.parse();
String TestText = new PDFTextStripper().getText(TestPDF.getPDDocument());
Assert.assertTrue(TestText.contains("Open the setting.xml, you can see it is like this"));
}
Bibliothèques de téléchargement: - https://pdfbox.apache.org/index.html