Skip to content
FMXExpressPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

pdftotext - Object Pascal PDF Text Extractor CLI

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.

Features

  • 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).

Requirements

  • Embarcadero Delphi (11 Alexandria / 12 Athens)
  • Supported compilers: dcc32 or dcc64

Project Layout

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

Build Instructions

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.dpr

This will produce the standalone executable pdftotext.exe.

Usage Examples

1. Help & Version

pdftotext --help
pdftotext --version

2. Extract Plain Text to stdout or file

pdftotext text Sample.pdf
pdftotext text Sample.pdf -o Output.txt

3. Parse and Save to History DB

pdftotext parse Sample.pdf
pdftotext parse https://example.com/document.pdf

4. Extract Specific Page Ranges

pdftotext text Sample.pdf -p 1,3-5,7

5. Get Metadata Info (Plain Text or JSON)

pdftotext info Sample.pdf
pdftotext info Sample.pdf -f json

6. Validate PDF Magic Header

pdftotext check Sample.pdf

7. Manage History DB

# 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 1

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages