A powerful, high-performance command-line interface (CLI) written in Object Pascal (Delphi) to extract text and metadata from PDF files, inspired by the Node.js pdf-parse package. It includes built-in history tracking using SQLite via FireDAC.
- Text Extraction: Extract text content from local PDF files or directly from HTTP/HTTPS URLs.
- Metadata Parsing: Read PDF document details (Title, Author, Creator, Producer, Page Count, Char Count, Word Count).
- Page Selection: Filter text extraction to specific page ranges (e.g.,
-p 1,3-5,7). - Output Formats: Output extracted data as plain text or structured JSON.
- PDF Header Verification: Validate PDF files by checking magic signature bytes (
%PDF). - History Tracking: Automatically record parsed files, metadata, and extracted text to a local SQLite database (allows listing, viewing, deleting, and calculating statistics).
- Embarcadero Delphi (11 Alexandria / 12 Athens)
- Supported compilers:
dcc32ordcc64
pdftotext/
pdftotext.dpr // Main program entry point
pdftotext.dproj // Delphi MSBuild project file
src/
pdftotext.App.pas // Orchestrator and core command-line dispatch
pdftotext.CLI.pas // CLI arguments parser and help screen
pdftotext.Database.pas // SQLite connection handler & schema migrations
pdftotext.PDFParser.pas // PDF structure parsing, text operator decoding, and ZLib decompression
README.md // Build and usage documentation
.gitignore // Build artifacts and database exclusion patterns
Compile with the Delphi Command-Line Compiler (dcc32 or dcc64) from the project root:
# Compile for Win32
dcc32 -B pdftotext.dpr
# Compile for Win64
dcc64 -B pdftotext.dprThis will produce the standalone executable pdftotext.exe.
pdftotext --help
pdftotext --versionpdftotext text Sample.pdf
pdftotext text Sample.pdf -o Output.txtpdftotext parse Sample.pdf
pdftotext parse https://example.com/document.pdfpdftotext text Sample.pdf -p 1,3-5,7pdftotext info Sample.pdf
pdftotext info Sample.pdf -f jsonpdftotext check Sample.pdf# List all parsed PDF files in history
pdftotext list
# Show text of a previously parsed PDF (using ID or filename)
pdftotext show 1
# Display statistics of history database
pdftotext stats
# Delete a parsed PDF from history
pdftotext delete 1This project is licensed under the MIT License.