{"course":{"slug":"ai-at-work","title":"AI at Work","url":"https://addaly.com/learn/ai-at-work","level":"beginner","track":"work"},"lesson":{"slug":"pdfs-forms-and-the-stack-on-your-desk","title":"PDFs, scans and the black rectangle that hides nothing","url":"https://addaly.com/learn/ai-at-work/pdfs-forms-and-the-stack-on-your-desk","position":42,"of":73,"minutes":9,"answer":"Try to select the text first: a born-digital PDF can be extracted exactly with no model involved, a scan needs OCR whose errors look like errors.","keyIdea":"Try to select the text first: a born-digital PDF can be extracted exactly with no model involved, a scan needs OCR whose errors look like errors, and a black box drawn over text leaves the text in the file."},"body":{"format":"markdown","text":"## The first thing to find out about any PDF\n\nOpen it and try to select a sentence with your mouse.\n\nIf the text highlights, it is a **born-digital PDF**: the characters are in the file, and they can be extracted exactly, by a tool, with no model and therefore no possibility of invention.\n\nIf nothing highlights, it is a **scan**: a photograph of a page wearing a PDF wrapper. There is no text in it at all. Anything you get out of it came from recognition, and recognition makes mistakes.\n\nTwo seconds, and it determines everything else you do. Enormous amounts of wasted effort, and a good number of wrong figures, come from people running a scanned invoice through a language model when the same invoice arrived by email as a born-digital file the week before.\n\n## Exact beats clever\n\nFor a born-digital PDF, use extraction, not intelligence:\n\n```bash\npdftotext -layout invoice.pdf invoice.txt\n```\n\n`pdftotext` is part of **poppler-utils**, free on every platform. The `-layout` flag preserves the spatial arrangement, which is what keeps table columns roughly aligned. What comes out is exactly what is in the file: no paraphrase, no rounding, no helpful correction.\n\nThen, if you want, hand the extracted text to a model for structuring. You have separated the two jobs (getting the characters, and understanding them) and only the second one can hallucinate.\n\n## When it is a scan\n\nRun OCR, and prefer a dedicated OCR engine over a vision model for anything numeric.\n\n```bash\nocrmypdf scan.pdf searchable.pdf\n```\n\n`ocrmypdf` wraps **Tesseract**, is free, works offline, and adds a text layer to the original. Tesseract handles over 100 languages, including scripts a general vision model handles unevenly.\n\nThe reason to prefer it for numbers is the failure mode. Tesseract, on a poor scan, produces `1O42`: obviously broken, and you go and look at the original. A vision model produces `1042`, cleanly, whether or not that is what the page says. Ugly and honest beats clean and possibly wrong, every time, for a figure that goes into an account.\n\n## Tables are the hard case\n\nPDF has no concept of a table. A table in a PDF is lines and text positioned on a page, and the row-and-column structure exists only in your eye.\n\nSo extraction of tables is difficult and everything struggles. `pdftotext -layout` gets you close for simple tables. **Tabula** is free, has a graphical interface, and was built specifically for pulling tables out of PDFs into CSV: for anyone regularly extracting financial tables it is the right tool. `camelot` does the same from Python.\n\nWhatever you use, validate arithmetically. If the table has 40 line items and a stated total, sum the 40 and compare. That single check verifies the entire extraction for free, and it is available far more often than people notice: invoices, payroll, budgets, stock counts, expense claims and results tables nearly all carry a total that has to reconcile.\n\n## Forms\n\nPDF forms come in two kinds. A live form has real fields that can be read and filled programmatically: `pdftk` or `qpdf` will list them. A **flattened** form has had the fields burned into the page and is functionally a scan.\n\nIf you are producing forms for other people to fill in, keep them live. If you are processing forms other people filled in by hand, you are doing handwriting recognition, with all the digit confusions covered earlier, and every figure needs checking against the original.\n\n## Redaction is not a black rectangle\n\nThis one has embarrassed governments, courts and law firms repeatedly, and it is still happening.\n\nDrawing a black box over text in a PDF adds a black box. **The text is still in the file**, underneath, and can be recovered by selecting and copying, or by running `pdftotext`. The same applies to white boxes, to highlighting in a viewer, and to \"hiding\" a layer.\n\nProper redaction removes the underlying content. Use a tool with a genuine redaction function that deletes the text, or take the crude reliable route: export the page to an image, black out the region in **GIMP**, and rebuild the PDF from the image. Then open the result and run `pdftotext` on it to confirm the words are gone. That final check takes ten seconds and is the only thing that actually proves it.\n\nPDFs also carry metadata: author, software, sometimes the original file name and path, which can itself disclose a client's name. `exiftool` shows it and `qpdf` or `mat2` can strip it.\n\n## The whole free stack\n\n**poppler-utils** for extraction, **ocrmypdf** and **Tesseract** for scans, **Tabula** for tables, **qpdf** for splitting, merging and metadata, **LibreOffice Draw** for editing a PDF's contents directly, and `exiftool` for what is hiding in the file properties.\n\nAll free, all offline, all deterministic. For document work that must not leave your machine, this stack does more of the job than any AI feature, and the AI is best used afterwards, on text you extracted exactly."},"check":{"question":"Why prefer Tesseract over a vision model for reading figures off a poor-quality scanned invoice?","options":[{"text":"Tesseract is more accurate than vision models on degraded scans.","correct":false,"tempting":"Claims a general accuracy win that often does not hold; on hard scans a vision model may read more characters correctly."},{"text":"Tesseract runs offline, so the invoice is not disclosed to a provider.","correct":false,"tempting":"Names a real and separate advantage, but it is about confidentiality rather than about which number you can trust."},{"text":"Where the scan is unreadable Tesseract emits visibly broken characters, whereas a vision model returns a clean plausible figure, so the failure announces itself instead of hiding.","correct":true},{"text":"Tesseract preserves the table structure, which vision models lose.","correct":false,"tempting":"Reverses the usual position: table structure is a weakness of plain OCR and one of the things vision models handle relatively well."}]},"prev":{"slug":"notebooks-and-the-private-corpus","title":"Notebooks that answer only from your sources","url":"https://addaly.com/learn/ai-at-work/notebooks-and-the-private-corpus"},"next":{"slug":"templates-merge-and-the-two-hundred-letters","title":"Two hundred letters, and only one generated paragraph","url":"https://addaly.com/learn/ai-at-work/templates-merge-and-the-two-hundred-letters"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'PDFs, scans and the black rectangle that hides nothing', in AI at Work. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/ai-at-work/pdfs-forms-and-the-stack-on-your-desk (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"PDFs, scans and the black rectangle that hides nothing","courseTitle":"AI at Work","module":{"index":5,"slug":"the-tools-on-your-desk","title":"The tools already on your desk"},"answer":null,"keyIdea":"Try to select the text first: a born-digital PDF can be extracted exactly with no model involved, a scan needs OCR whose errors look like errors, and a black box drawn over text leaves the text in the file.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"the-first-thing-to-find-out-about-any-pdf","runs":[{"text":"The first thing to find out about any PDF"}]},{"t":"p","runs":[{"text":"Open it and try to select a sentence with your mouse."}]},{"t":"p","runs":[{"text":"If the text highlights, it is a "},{"text":"born-digital PDF","b":true},{"text":": the characters are in the file, and they can be extracted exactly, by a tool, with no model and therefore no possibility of invention."}]},{"t":"p","runs":[{"text":"If nothing highlights, it is a "},{"text":"scan","b":true},{"text":": a photograph of a page wearing a PDF wrapper. There is no text in it at all. Anything you get out of it came from recognition, and recognition makes mistakes."}]},{"t":"p","runs":[{"text":"Two seconds, and it determines everything else you do. Enormous amounts of wasted effort, and a good number of wrong figures, come from people running a scanned invoice through a language model when the same invoice arrived by email as a born-digital file the week before."}]},{"t":"h2","id":"exact-beats-clever","runs":[{"text":"Exact beats clever"}]},{"t":"p","runs":[{"text":"For a born-digital PDF, use extraction, not intelligence:"}]},{"t":"code","lang":"bash","label":"Bash","text":"pdftotext -layout invoice.pdf invoice.txt"},{"t":"p","runs":[{"text":"pdftotext","code":true},{"text":" is part of "},{"text":"poppler-utils","b":true},{"text":", free on every platform. The "},{"text":"-layout","code":true},{"text":" flag preserves the spatial arrangement, which is what keeps table columns roughly aligned. What comes out is exactly what is in the file: no paraphrase, no rounding, no helpful correction."}]},{"t":"p","runs":[{"text":"Then, if you want, hand the extracted text to a model for structuring. You have separated the two jobs (getting the characters, and understanding them) and only the second one can hallucinate."}]},{"t":"h2","id":"when-it-is-a-scan","runs":[{"text":"When it is a scan"}]},{"t":"p","runs":[{"text":"Run OCR, and prefer a dedicated OCR engine over a vision model for anything numeric."}]},{"t":"code","lang":"bash","label":"Bash","text":"ocrmypdf scan.pdf searchable.pdf"},{"t":"p","runs":[{"text":"ocrmypdf","code":true},{"text":" wraps "},{"text":"Tesseract","b":true},{"text":", is free, works offline, and adds a text layer to the original. Tesseract handles over 100 languages, including scripts a general vision model handles unevenly."}]},{"t":"p","runs":[{"text":"The reason to prefer it for numbers is the failure mode. Tesseract, on a poor scan, produces "},{"text":"1O42","code":true},{"text":": obviously broken, and you go and look at the original. A vision model produces "},{"text":"1042","code":true},{"text":", cleanly, whether or not that is what the page says. Ugly and honest beats clean and possibly wrong, every time, for a figure that goes into an account."}]},{"t":"h2","id":"tables-are-the-hard-case","runs":[{"text":"Tables are the hard case"}]},{"t":"p","runs":[{"text":"PDF has no concept of a table. A table in a PDF is lines and text positioned on a page, and the row-and-column structure exists only in your eye."}]},{"t":"p","runs":[{"text":"So extraction of tables is difficult and everything struggles. "},{"text":"pdftotext -layout","code":true},{"text":" gets you close for simple tables. "},{"text":"Tabula","b":true},{"text":" is free, has a graphical interface, and was built specifically for pulling tables out of PDFs into CSV: for anyone regularly extracting financial tables it is the right tool. "},{"text":"camelot","code":true},{"text":" does the same from Python."}]},{"t":"p","runs":[{"text":"Whatever you use, validate arithmetically. If the table has 40 line items and a stated total, sum the 40 and compare. That single check verifies the entire extraction for free, and it is available far more often than people notice: invoices, payroll, budgets, stock counts, expense claims and results tables nearly all carry a total that has to reconcile."}]},{"t":"h2","id":"forms","runs":[{"text":"Forms"}]},{"t":"p","runs":[{"text":"PDF forms come in two kinds. A live form has real fields that can be read and filled programmatically: "},{"text":"pdftk","code":true},{"text":" or "},{"text":"qpdf","code":true},{"text":" will list them. A "},{"text":"flattened","b":true},{"text":" form has had the fields burned into the page and is functionally a scan."}]},{"t":"p","runs":[{"text":"If you are producing forms for other people to fill in, keep them live. If you are processing forms other people filled in by hand, you are doing handwriting recognition, with all the digit confusions covered earlier, and every figure needs checking against the original."}]},{"t":"h2","id":"redaction-is-not-a-black-rectangle","runs":[{"text":"Redaction is not a black rectangle"}]},{"t":"p","runs":[{"text":"This one has embarrassed governments, courts and law firms repeatedly, and it is still happening."}]},{"t":"p","runs":[{"text":"Drawing a black box over text in a PDF adds a black box. "},{"text":"The text is still in the file","b":true},{"text":", underneath, and can be recovered by selecting and copying, or by running "},{"text":"pdftotext","code":true},{"text":". The same applies to white boxes, to highlighting in a viewer, and to “hiding” a layer."}]},{"t":"p","runs":[{"text":"Proper redaction removes the underlying content. Use a tool with a genuine redaction function that deletes the text, or take the crude reliable route: export the page to an image, black out the region in "},{"text":"GIMP","b":true},{"text":", and rebuild the PDF from the image. Then open the result and run "},{"text":"pdftotext","code":true},{"text":" on it to confirm the words are gone. That final check takes ten seconds and is the only thing that actually proves it."}]},{"t":"p","runs":[{"text":"PDFs also carry metadata: author, software, sometimes the original file name and path, which can itself disclose a client’s name. "},{"text":"exiftool","code":true},{"text":" shows it and "},{"text":"qpdf","code":true},{"text":" or "},{"text":"mat2","code":true},{"text":" can strip it."}]},{"t":"h2","id":"the-whole-free-stack","runs":[{"text":"The whole free stack"}]},{"t":"p","runs":[{"text":"poppler-utils","b":true},{"text":" for extraction, "},{"text":"ocrmypdf","b":true},{"text":" and "},{"text":"Tesseract","b":true},{"text":" for scans, "},{"text":"Tabula","b":true},{"text":" for tables, "},{"text":"qpdf","b":true},{"text":" for splitting, merging and metadata, "},{"text":"LibreOffice Draw","b":true},{"text":" for editing a PDF’s contents directly, and "},{"text":"exiftool","code":true},{"text":" for what is hiding in the file properties."}]},{"t":"p","runs":[{"text":"All free, all offline, all deterministic. For document work that must not leave your machine, this stack does more of the job than any AI feature, and the AI is best used afterwards, on text you extracted exactly."}]}],"check":{"question":[{"text":"Why prefer Tesseract over a vision model for reading figures off a poor-quality scanned invoice?"}],"options":[{"text":[{"text":"Tesseract is more accurate than vision models on degraded scans."}],"correct":false,"tempting":[{"text":"Claims a general accuracy win that often does not hold; on hard scans a vision model may read more characters correctly."}]},{"text":[{"text":"Tesseract runs offline, so the invoice is not disclosed to a provider."}],"correct":false,"tempting":[{"text":"Names a real and separate advantage, but it is about confidentiality rather than about which number you can trust."}]},{"text":[{"text":"Where the scan is unreadable Tesseract emits visibly broken characters, whereas a vision model returns a clean plausible figure, so the failure announces itself instead of hiding."}],"correct":true,"tempting":null},{"text":[{"text":"Tesseract preserves the table structure, which vision models lose."}],"correct":false,"tempting":[{"text":"Reverses the usual position: table structure is a weakness of plain OCR and one of the things vision models handle relatively well."}]}],"order":[3,2,0,1],"why":null},"prev":{"slug":"notebooks-and-the-private-corpus","title":"Notebooks that answer only from your sources","minutes":9},"next":{"slug":"templates-merge-and-the-two-hundred-letters","title":"Two hundred letters, and only one generated paragraph","minutes":8}}}