Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
/ PdfBox Public
forked from schmengler/PdfBox

A PHP interface for the Apache PdfBox ExtractText utility, useful to unit-test contents of generated PDFs

License

Notifications You must be signed in to change notification settings

ul8/PdfBox

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PdfBox

A PHP interface for the PdfBox ExtractText utility, useful to unit-test contents of generated PDFs.

Build Status Latest Stable Version Latest Unstable Version Total Downloads License

Requirements

  • PHP >=5.3 or HHVM
  • Java Runtime Environment
  • PdfBox JAR file
  • PHP needs permissions for shell execution

Install

To install with composer:

composer require sgh/pdfbox

Basic Usage

use SGH\PdfBox\PdfBox;

//$pdf = GENERATED_PDF;
$converter = new PdfBox;
$converter->setPathToPdfBox('/usr/bin/pdfbox-app-1.7.0.jar');
$text = $converter->textFromPdfStream($pdf);
$html = $converter->htmlFromPdfStream($pdf);
$dom  = $converter->domFromPdfStream($pdf);

If the source PDF is a file, use xxxFromPdfFile() instead xxxFromPdfStream() with the source path as parameter.

If you want to save the converted output to a file, specify the destination path as second parameter of the xxxFromPdfxxx() methods.

Advanced Usage

Convert a range of pages instead of the full document:

$converter->getOptions()
    ->setStartPage(2)
	->setEndPage(5);

Ignore corrupt objects in the PDF:

$converter->getOptions()
    ->setForce(true);

Sort text:

$converter->getOptions()
    ->setSort(true);

Set path to java executable (if not in path):

$converter->setPathToJava("/path/to/java/bin/java");

PHPUnit tests

To run the unit tests, change the environment variable PDFBOX_JAR to the full path of your PdfBox JAR file. See phpunit.xml.dist.

About

A PHP interface for the Apache PdfBox ExtractText utility, useful to unit-test contents of generated PDFs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.