Pdfgrep 在 PDF 內尋找指定字串

https://pdfgrep.org/

install

sudo apt-get update -y
sudo apt-get install -y pdfgrep

create searchTextInPDF.sh
chmod +x searchTextInPDF.sh

#!/bin/bash

pdfgrep -n $1 $2 | grep $1 &> /dev/null
if [ $? == 0 ]; then
   echo "✅ matched"
else 
    echo "❌ not matched"
fi

usage:

e.g.

./searchTextInPDF {KEYWORD} {PDF_FILE_PATH_WITH_FILENAME}
./searchTextInPDF 可樂有限公司 110年度可樂有限公司營所稅申報書.pdf

Ref.

about OCR for image in PDF

https://www.twblogs.net/a/60b9b79ad7b86f43f4c497cd/?lang=zh-cn