Generally
Your PDF looks botched. I entirely concur with @JohnO on his initial comment. There's almost zero chance that with any of the current OCR techniques, you'd get a satisfying result. However, given the content you show, I'm pretty sure you can obtain a perfectly searchable PDF copy of this book.
Approach 1: Going the 'OCR' way
Having said that, you can use tesseract
for OCR. Don't forget to specify both the eng and fra language in on invoking tesseract
. Or use one of the derived scripts to add a searchable text layer into the PDF:
Approach 2: Going the 'Compression' way
If you want to go along the path of compressing the PDF, you probably need to play with sampling methods, given that you stated that simply changing DPI didn't necessarily do the trick. One approach using ghostscript
is as follows (bash
needed, works on wsl
as well):
#!/usr/bin/env bash
# Parametrization : https://www.ghostscript.com/doc/current/VectorDevices.htm#distillerparams
# Display defaults: gs -q -dNODISPLAY -c ".distillersettings /screen get {exch ==only ( ) print ===} forall quit" | sort
input=$1
output=$2
: ${QFACTOR:="0.4"}
: ${RES:="150"}
echo "Using QFACTOR=$QFACTOR RES=$RES"
gs \
-o $output \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/screen \
-dCompatibilityLevel=1.8 \
-dDetectDuplicateImages=true \
-dAutoRotatePages=/None \
-dEmbedAllFonts=false \
-dSubsetFonts=true \
-dConvertCMYKImagesToRGB=true \
-dCompressFonts=true \
-dColorImageDownsampleType=/Bicubic \
-dColorImageResolution=${RES} \
-dGrayImageDownsampleType=/Bicubic \
-dGrayImageResolution=${RES} \
-dMonoImageDownsampleType=/Bicubic \
-dMonoImageResolution=${RES} \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-dCompressPages=true \
-c "<< /ColorImageDict << /QFactor ${QFACTOR} /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >> >> setdistillerparams" \
-c '<</AlwaysEmbed [ ]>> setdistillerparams' \
-c '<</NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats /Arial]>> setdistillerparams' \
-f $input
In any case, unless you're ready to delve very deep into the PS/PDF/compression/OCR world, it probably is best to get a better electronic copy of the book, or upload the PDF somewhere for us to look at it.