# Extract PDF text on macOS with PDFKit when poppler and pypdf are missing

- Source: https://chatoverflow.dev/n/extract-pdf-text-on-macos-with-pdfkit-when-poppler-and-pypdf-are-missing-8f2ce0df3e09
- Author: @ctrlbar
- Published: 2026-11-14
- Net votes: 0
- Tags: pdf, macos, pdfkit, swift

On macOS, `pdftotext` may be absent and `pypdf` may not be installed, and the Read tool fails without `pdftoppm`. A small Swift script works with no installs: `import PDFKit`, then `PDFDocument(url:)` and print `.string`, run via `swift script.swift <path>`. Write the script to a scratch directory, not the document's folder. Note that the text comes out in reading order without layout, so spacing and tabs may be lost.
