OCR a PDF on a Mac: 4 ways
1,936 of 1,955
words, Apple's engine, no third-party install
Your Mac already has OCR
- One page: Live Text in Preview.
- A whole PDF: our Swift script.
- A searchable PDF: OCRmyPDF.
- From a server: our Actor.
Apple's engine read the most words
| Way | Install | Words, time |
|---|---|---|
| Live Text API | Command Line Tools (free, Apple) | 1,936 in 3.5 s, 3.2 s |
| Vision documents | Command Line Tools, macOS 26 | 1,936 in 8.2 s, 8.3 s |
| Vision accurate | Command Line Tools (free, Apple) | 1,930 in 8.9 s, 8.1 s |
| Tesseract 5.5.4 | Homebrew | 1,877 in 30.1 s |
| OCRmyPDF 17.13.0 | uv here (Homebrew or pip also) | 1,855 in 27.1 s |
| pdf-ocr Actor, live run | None on the Mac (HTTP call) | 1,875 in 278.5 s |
One run each. Apple's three ran twice, in two orders. Tesseract and OCRmyPDF had 2 cores; Apple's engines had no cap.
Way 1: one page, with Live Text
For an image or a screenshot:
- Open the image in Preview.
- Drag across the text, Control-click it, and choose Copy Text.
- Cannot select it? Choose Tools > Text Selection.
Not tested here: these clicks. We tested the Live Text API in code.
Screenshots: our TextSniper alternatives test.
Way 2: a whole PDF, with Apple's engine
pdfocr.swift prints the text of every page, read by Apple's engine at 300 dpi.
It needs swiftc with the macOS 26 SDK: Xcode 26, or Apple's free
Command Line Tools (xcode-select --install).
swiftc -O pdfocr.swift -o pdfocr
./pdfocr scan.pdf > scan.txt
./pdfocr scan.pdf livetext > scan.txt
./pdfocr scan.pdf docs > scan.txt
-
The default is Vision accurate, in English.
livetextis the Live Text API, the fastest in this test. -
docsneeds macOS 26. Vision and Live Text are for macOS 13 and later, not run there. - Tested on macOS 26.6 only.
pdfocr.swift, the whole script
// OCR a scanned PDF on a Mac with Apple's own text engine. Prints the text of every page.
// Build: swiftc -O pdfocr.swift -o pdfocr
// Run: ./pdfocr scan.pdf > scan.txt (Vision, accurate)
// ./pdfocr scan.pdf livetext > scan.txt (the Live Text API, VisionKit ImageAnalyzer)
// ./pdfocr scan.pdf docs > scan.txt (Vision RecognizeDocumentsRequest, needs macOS 26)
import AppKit
import PDFKit
import Vision
import VisionKit
let args = CommandLine.arguments
guard args.count > 1, let pdf = PDFDocument(url: URL(fileURLWithPath: args[1])) else {
fputs("usage: pdfocr <file.pdf> [vision|livetext|docs]\n", stderr)
exit(1)
}
let mode = args.count > 2 ? args[2] : "vision"
// Each page as an image at 300 dpi on white (the crop box, as Preview shows it; turned pages stay whole).
func render(_ page: PDFPage) -> CGImage {
let box = page.bounds(for: .cropBox), s: CGFloat = 300 / 72
let turned = page.rotation % 180 != 0
let w = Int((turned ? box.height : box.width) * s), h = Int((turned ? box.width : box.height) * s)
let ctx = CGContext(data: nil, width: w, height: h, bitsPerComponent: 8, bytesPerRow: 0,
space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.noneSkipLast.rawValue)!
ctx.setFillColor(.white)
ctx.fill(CGRect(x: 0, y: 0, width: w, height: h))
ctx.scaleBy(x: s, y: s)
page.draw(with: .cropBox, to: ctx)
return ctx.makeImage()!
}
func vision(_ img: CGImage) throws -> String {
let req = VNRecognizeTextRequest()
req.recognitionLevel = .accurate
req.usesLanguageCorrection = true
try VNImageRequestHandler(cgImage: img, orientation: .up).perform([req])
return (req.results ?? []).compactMap { $0.topCandidates(1).first?.string }.joined(separator: "\n")
}
@MainActor func page(_ img: CGImage) async throws -> String {
switch mode {
case "livetext":
return try await ImageAnalyzer().analyze(img, orientation: .up, configuration: .init([.text])).transcript
case "docs":
guard #available(macOS 26, *) else { throw CocoaError(.featureUnsupported) }
return try await RecognizeDocumentsRequest().perform(on: img).map { $0.document.text.transcript }
.joined(separator: "\n")
default:
return try vision(img)
}
}
Task { @MainActor in
for i in 0..<pdf.pageCount {
do {
print(try await page(render(pdf.page(at: i)!)))
} catch {
fputs("page \(i + 1): \(error)\n", stderr)
exit(1)
}
}
exit(0)
}
RunLoop.main.run()
Way 3: a searchable PDF, with OCRmyPDF
OCRmyPDF is a free tool that adds a text layer to a scanned PDF.
brew install ocrmypdf
ocrmypdf scan.pdf scan-ocr.pdf
-
Tested: 17.13.0 from
uv tool install ocrmypdf, no Ghostscript. Homebrew gives 17.14.2 with Ghostscript, not run here. -
27.1 s for our 10 pages. We kept it to two cores with
--jobs 2; the default uses all. - Output here: a PDF/A-2b of 6.49 MB, the same size as the scan. Homebrew's Ghostscript can change the size.
- Its text layer, read with pdftotext: 1,855 words, 22 fewer than plain Tesseract.
Way 4: text from any app or server
Our Apify Actor, PDF to Markdown OCR, reads a PDF from a URL in the cloud. A short PDF is one HTTP call.
- On this scan it read fewer words than Apple's engine: 1,875 against 1,936.
- On this scan: plain paragraphs, no Markdown marks.
- Our 10 pages took 278.5 s; Apify's one-call limit is 300 s.
- Longer PDFs: start a run and poll it, as in our C# guide.
- $0.006 per OCR page. Pages with their own text layer are free.
Same 10 pages as our n8n test
Proofread Wikisource scans, 1,955 words, scored as true words found in order.
Not tested: the Live Text clicks in Preview or Photos, search in Preview, Shortcuts, paid apps.
How we ran it
- Apple M5 Max, 128 GB, macOS 26.6.
- One run at a time, at low priority, while other work ran, so times are rough.
- The scan: one 6.49 MB PDF, each page a 300 dpi JPEG.
- pdfocr.swift ran as printed. It draws each page's crop box, and keeps turned pages whole.
- Built with Xcode 26's swiftc (Swift 6.4.2). A second build used only the Command Line Tools.
- Vision and Live Text: type-checked for macOS 13 and 15 with the macOS 26 SDK, not built or run there.
- vision: VNRecognizeTextRequest, accurate, language correction on, the default language (en-US), no language detection.
-
Other languages: set
req.recognitionLanguages, for example to["de-DE"]. Not tested here. - livetext: VisionKit ImageAnalyzer, its transcript. docs: RecognizeDocumentsRequest, new in macOS 26.
- Apple does not say that Preview or Photos use the Live Text API.
- The Apple rerun, in the other order, gave the same three texts.
- The livetext and docs texts are not the same, but each finds 1,936 words.
- Tesseract 5.5.4 from Homebrew: psm 3, English, 2 threads, on the page JPEGs.
- Homebrew lists Tesseract 5.5.5 today.
- OCRmyPDF 17.13.0 ran Homebrew's Tesseract 5.5.4. pdftotext from Poppler 26.03.0 read its text.
- pdftotext joins split words, but loses some spaces and hyphens ("theroom?") and reads some quotes another way.
- The Actor row is an earlier run on this scan: build 0.1.145 on Apify, at 1,024 MB.
- Scripts and results stay in our private repo, in research/bench/ocr-mac-2026-11-26/.
Questions people ask
Can a Mac OCR a PDF without an app?
Yes. Apple's text engine comes with macOS. Our short Swift script reads every page of a scanned PDF with it, and found 1,936 of 1,955 words on our scan. It needs Apple's free Command Line Tools.
How do I make a scanned PDF searchable on a Mac?
Install OCRmyPDF, then run
ocrmypdf scan.pdf scan-ocr.pdf. It adds a text layer
to the PDF. On our scan, pdftotext read 1,855 words from it.
Is Apple's OCR better than Tesseract?
On our 10-page book scan, yes: Apple's engine found up to 1,936 words, Tesseract 1,877. Apple's needs no third-party install.
Related guides
- Apple Vision OCR vs Tesseract, tested on 523 scans
- How to make a PDF searchable: scanned PDFs, tested
- Free TextSniper alternatives on Mac, tested on 32 screenshots
- Free ABBYY FineReader alternatives for Mac and Linux, tested
- Swift OCR on macOS: 4 Apple APIs tested, with code
- PDF OCR API: a scanned PDF to Markdown in one call