@@ -3,9 +3,7 @@ const fs = require("fs");
33const pdfjsLib = require ( "pdfjs-dist/legacy/build/pdf.js" ) ;
44const { PNG } = require ( "pngjs" ) ;
55const sharp = require ( "sharp" ) ;
6- const extractText = require ( "pdf-text-extract" ) ;
7- const util = require ( "util" ) ;
8- const extractTextAsync = util . promisify ( extractText ) ;
6+ const pdfParse = require ( "pdf-parse" ) ;
97
108module . exports = defineConfig ( {
119 e2e : {
@@ -34,6 +32,13 @@ module.exports = defineConfig({
3432 let logoFound = false ;
3533 let extractedText = "" ;
3634
35+ // Text extraction Node-only
36+ if ( options . checkText ) {
37+ const dataBuffer = fs . readFileSync ( filePath ) ;
38+ const pdfData = await pdfParse ( dataBuffer ) ;
39+ extractedText = pdfData . text ;
40+ }
41+
3742 // Pixelmatch lazy import
3843 let pixelmatch ;
3944 if ( options . referenceLogoPath ) {
@@ -43,13 +48,6 @@ module.exports = defineConfig({
4348
4449 for ( let p = 1 ; p <= pdfDoc . numPages ; p ++ ) {
4550 const page = await pdfDoc . getPage ( p ) ;
46-
47- // Text extraction
48- if ( options . checkText ) {
49- const pagesText = await extractTextAsync ( filePath ) ;
50- extractedText = pagesText . join ( "\n" ) ;
51- }
52-
5351 const ops = await page . getOperatorList ( ) ;
5452
5553 for ( let i = 0 ; i < ops . fnArray . length ; i ++ ) {
0 commit comments