4 ms·
>The text is "sandwiched" behind the image of the page, so you can't see it but can search for it. I already have a bunch of these PDFs that have this. Does an
by fouc 5y ago
>The text is "sandwiched" behind the image of the page, so you can't see it but can search for it.
I already have a bunch of these PDFs that have this. Does anyone know how to extract this text out?
In particular I'd like to make it into a nice mobi/epub file, but calibre doesn't do this on its own.
- edent 5y agoAt a basic level, you can copy and paste it out. CTRL+A, CTRL+C, CTRL+V. Done. You can also use Poppler's PDFtoText https://en.wikipedia.org/wiki/Pdftotext https://en.wikipedia.org/wiki/Pdftotext Calibre struggles with some PDFs, especially those that don't contain metadata about chapter headings etc. That's a failing on the PDF, not Calibre.
- deleted 5y ago[deleted]
- lelandfe 5y agoAs always, Ghostscript is the way. $ gs sDEVICE=txtwrite -o output.txt input.pdf
- sandreas 5y agoAwesome, I did not know that this works :-) Thank you.
- stonewareslord 5y agoAdditionally, some PDFs (like textbooks) insert intentionally mangled embedded text to prevent copying/pasting. You can rasterize them and push them through pdfsandwich/ocrmypdf to wipe these hidden layers and re-ocr them. Haven't done it in a while, but looks like this should work: https://askubuntu.com/a/845119 https://askubuntu.com/a/845119 Obviously replace convert with mogrify ./* after backing them up
- lelandfe 5y agoGreat note! ocrmypdf can also output the OCR’d text as a file using the oddly named “sidecar” parameter. $ ocrmypdf --sidecar text.txt input.pdf output.pdf