2017 © Pedro Peláez
 

library php-pdfbox

PHP-PDFBox

image

php-pdfbox/php-pdfbox

PHP-PDFBox

  • Monday, July 9, 2018
  • by temp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 250 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

PHP-PDFbox

PHP-PDFBox is a tiny library which acts as a wrapper facilitating the use of PDFBox https://pdfbox.apache.org/ in PHP., (*1)

It provides a simple API for calling the pdfbox-app.jar. The library is currently restricted to functionality provided by PDFbox's command-line utilities. It currently supports PDFBox version 2., (*2)

PDFBox is published under the Apache License v2.0 and is described as "The Apache PDFBox® library is an open source Java tool for working with PDF documents.", (*3)

Installation

It is recommended to install PHP-PDFBox through Composer :, (*4)

{
    "require": {
        "php-pdfbox/php-pdfbox": "^2.0"
    }
}

pdfbox-app.jar is included in the installation. You can/should verify the integrity of pdfbox-app.jar with the PGP signatures available at https://pdfbox.apache.org/download.html., (*5)

Main API usage:

Basic usage can be done as follows:, (*6)

$file = new \Pdfbox\Processor\PdfFile(
    new Pdfbox(
        '/path/to/java',
        '/path/to/pdfbox-app.jar'
    );
);

// Convert pdf to text
echo $file->toText('test.pdf');

(Providing a Logger object is optional in v2.0.2+.) To use with psr/log and a PSR-3 compliant logger, do something like:, (*7)

use Psr\Log\LoggerInterface;
use MyPSR3Logger;

class Foo
{
    private $logger;

    public function __construct(LoggerInterface $logger = null){
        $this->logger = $logger;
    }

    public function doPdfBox(){
        try {
            $file = new \Pdfbox\Processor\PdfFile(
                new Pdfbox(
                    '/path/to/java',
                    '/path/to/pdfbox-app.jar',
                    $this->logger;
                );
            );
            // Convert pdf to text
            echo $file->toText('test.pdf');
        } catch (Exception $e) {
            $this->logger->error($e->getMessage(), ['exception', $e->backtrace()]);
        }
    }
}
$myLogger = new MyPSR3Logger();
$foo = new Foo($myLogger);

See examples/ConsoleLogger.php for a standard PSR3 compliant logger class that can be be copied and adapted., (*8)

See examples/*.php for more examples., (*9)

API Documentation

HTML Documentation generated by phpDocumentor can be found in docs/api., (*10)

License

PHP-Pdfbox is released under MIT License http://opensource.org/licenses/MIT, (*11)

See LICENSE file for more information., (*12)

The Versions

09/07 2018

dev-master

9999999-dev

PHP-PDFBox

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf pdfbox

09/07 2018

1.0.0

1.0.0.0

PHP-PDFBox

  Sources   Download

MIT

The Requires

 

The Development Requires

pdf pdfbox