Download the PHP package avvertix/liteparse-php without Composer

On this page you can find all versions of the php package avvertix/liteparse-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package liteparse-php

liteparse-php

Native PHP bindings for LiteParse, local PDF and document parsing with spatial text extraction powered by Rust and PDFium.

Given a PDF this package extracts text with bounding boxes and renders it as structured JSON, plain text, or layout-aware Markdown (headings, lists, tables, figure references). The parsing happens directly from PHP, via a compiled Rust cdylib loaded through PHP's FFI extension.

[!NOTE] The native bindings are tested only for PDF files. Support for DOC/DOCX/XLS/XLSX/PPT/PPTX, and images is not tested and not provided so far.

Requirements

Installation

Get the package via Composer and install the native library for your platform.

install downloads the compiled liteparse_php library and its PDFium dependency for your platform from the package's GitHub Releases into vendor/avvertix/liteparse-php/lib/. The specific installed versions are recorded in a natives.lock file in the root of your project, commit this alongside composer.lock to install the same version of the compiled binary. Run vendor/bin/liteparse-php update after upgrading the package to fetch the matching native library.

Quick start

json() returns liteparse's full per-item TextItem — not the lean {text, x, y, width, height} shape the upstream lit CLI's own --format json produces. Each item carries its bounding box together with font_size and fill_color/stroke_color (ARGB hex, e.g. "ff000000") on the same record, plus rotation, links, strikethrough, and OCR confidence where applicable. Font/color fields are only populated for native PDF text; OCR-derived items carry null there instead.

lines() sits between json() and markdown(): each entry is a merged visual line (one or more TextItems sharing a baseline) carrying its own bounding box, dominant font/style, and region_path — the xy-cut column/region position liteparse uses internally to group paragraphs and tables. Each line's spans field keeps the original TextItems that merged into it, so per-run font/color survives even where the line's own text concatenates multiple items. Unlike markdown(), nothing here is reformatted or dropped when the heuristic table/heading detection misfires — you get the raw geometry and can reconstruct rows/columns/headings yourself from region_path and bbox positions. There is no heading/paragraph/list "role" label at this layer.

With Config::$extractBlocks on, json() also attaches a per-page blocks array: the same classified heading/paragraph/list/table/figure decomposition markdown() renders from, exposed as data with a bounding box on every block (the union of every source line that fed it) — including a bbox on every table cell. Independent of outputFormat; enabling it never changes the rendered Markdown.

With Config::$extractDocumentMetadata and Config::$continueOnPageError on, json()'s top level also carries doc_meta (dates, encryption, signatures, incremental-save markers, raw XMP) and page_errors (page-level extraction failures that didn't abort the parse); total_pages (source page count before maxPages/targetPages truncation) is always present.

Every ParseResult accessor (text(), markdown(), json(), lines()) renders on demand from the same underlying parsed pages.

Features

See examples/ for runnable scripts.

Configuration

Config mirrors liteparse's Rust LiteParseConfig field-for-field:

Field Default Notes
ocrLanguage 'eng' Tesseract-format language code
ocrEnabled false Requires ocrServerUrl — this binding has no built-in OCR engine
ocrServerUrl null HTTP OCR server URL
ocrServerHeaders [] [[name, value], ...] sent with every OCR request
maxPages 1000
targetPages null e.g. "1-5,10,15-20"; null = all pages
dpi 150.0 Used for OCR and screenshots
outputFormat OutputFormat::Json Informational only in this binding — text()/markdown()/json() are always available regardless
preserveVerySmallText false
password null For encrypted/protected documents
quiet true Suppresses liteparse's stderr progress logging (Rust default is false)
numWorkers 1 Concurrent OCR requests to the HTTP server
imageMode ImageMode::Placeholder Affects markdown() image references only
extractLinks true Hyperlinks as [text](url) in markdown
extractImages false Extract embedded image bytes/metadata into ParseResult.images
imageOutputDir null Directory where extracted embedded images are written; requires extractImages
extractAnnotations false Extract all PDF annotations into each parsed page
cropBox null Restrict output to a sub-region of every page: ['top' => ..., 'right' => ..., 'bottom' => ..., 'left' => ...] fractions
skipDiagonalText false Drop text items rotated more than 2° off the nearest right angle
ocrFailureFatal true Abort the whole parse on systemic OCR failure vs. return degraded results
ocrHedgeDelaysMs [] Request-hedging schedule for the HTTP OCR engine
emitWordBoxes false Per-word sub-boxes on each text item (roughly doubles payload size)
includeComplexity false Attach a complexity object (text/image coverage, OCR reasons, layout signals) to each page in json()
keepHeadersFooters false Keep running headers/footers in markdown() instead of stripping them
extractVectorGraphics false Expose page-scoped vector path data (shapes, merged lines) in parse results
extractBlocks false Attach a blocks array (headings, paragraphs, tables with per-cell boxes, figures, ...) with bounding boxes to each page in json()
extractDocumentMetadata false Populate json()'s top-level doc_meta (dates, encryption, signatures, incremental-save markers, raw XMP)
extractScreenshots false Render every page to PNG during parseFile()/parseBytes(), available via ParseResult::screenshots()
continueOnPageError false Continue past a page-level extraction failure instead of aborting the parse; failures land in json()'s top-level page_errors

How it works

LiteParse Rust create is exposed as C library to be consumed by the PHP Foreign Function Interface (FFI). The shared library is defined in rust/ exposing handles for the parser/result/screenshot-list lifecycle, plus configuration and exceptions. LiteParse's API is async (tokio-based); the FFI layer owns a single process-wide tokio runtime and block_ons each call, since PHP FFI calls are synchronous. cbindgen generates the committed include/liteparse_php.h header that PHP's FFI::cdef() loads.

PDFium (a separate native dependency liteparse links against) is discovered at runtime by pdfium-sys's loader relative to whichever shared library loaded it.

Development

Adding a new FFI function: add the extern "C" function in rust/src/ffi/, rebuild (cbindgen regenerates include/liteparse_php.h automatically via build.rs), add the corresponding @method annotation to LiteParseFfi, and wrap it in a PHP class.

Building from source

If you're working in this repository directly (or no prebuilt release exists yet for your platform):

scripts/build.sh compiles the Rust crate in rust/ and copies the resulting native library, plus its PDFium runtime dependency, into lib/.

License

The project is dual licenced. The PHP wrapper code is licenced under Apache-2.0.


All versions of liteparse-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-ffi Version *
composer-runtime-api Version ^2.0
symfony/console Version ^6.4|^7.0|^8.0|^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package avvertix/liteparse-php contains the following files

Loading the files please wait ...