PHP XPDF Documentation

Similar documents
PHP-SwfTools Documentation

Project Name Documentation

Navigator Documentation

Magister 6 API Documentation

Composer Best Practices Nils Private Packagist

Magister 6 API Documentation

Firebase Admin SDK for PHP. Release

Blast Project. Release

Firebase Admin SDK for PHP

MediaVorus Documentation

Drupal Drivers Documentation

Kinto Documentation. Release Mozilla Services Da French Team

Instagram PHP Documentation

Full Stack JavaScript: Learn Backbone.js, Node.js And MongoDB By Azat Mardan

Scaffold Documentation

Bldr.io Documentation

Silex and Twig. Jon Ginn

Payment Suite. Release

ReferralSystemDemoBundle Documentation

The Rock branching strategy is based on the Git Branching Model documented by Vincent Driessen.

JiFile. Documentation and PDF Optimization Manual. By Matthias Kleespies, Germany germanclimateblog.com principia-scientific.org

CuteFlow-V4 Documentation

The Laravel Survival Guide

Getting started with GitHub

contribution-guide.org Release

PHP-Einführung - Lesson 8 - Composer (Dependency manager) and JSON. Alexander Lichter June 27, 2017

Behat BDD, FUNCTIONAL TESTS & SELENIUM (IN DRUPAL!)

How to contribute to Symfony for Symfony 2.1

What's New with MunkiReport. John Eberle

Composer and Drupal. CIDUG Meeting December 13, 2018 John Rearick

Could Not Fetch Schema Routine Status Mysql

Continuous integration & continuous delivery. COSC345 Software Engineering

Mantis STIX Importer Documentation

Chargify SDK for PHP Documentation

Force Login USER GUIDE

Using CICS Dynamic Scripting

Software Development I

Le L c e t c ur u e e 5 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Exception Handling

Dependency Injection Container Documentation

Managed Make Project File Error Code Composer

JoomDOC Documentation

README for X11R7.5. The X.Org Foundation 1. October 2009

Migration Tool Developer's Guide

PACE Suite. Release Notes. Version Document version

Django MFA Documentation

TYPO3 Version What s New Summary of the new features, changes and improvements

bottle-rest Release 0.5.0

Daedalus Documentation

SYMFONY2 WEB FRAMEWORK

Can R Speak Your Language?

Exception handling & logging Best Practices. Angelin

PHP-FCM Documentation

COMPOSER IN DRUPAL WORLD

Pdf in chrome problem. Pdf in chrome problem.zip

dj-libcloud Documentation

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani -

ECE 122. Engineering Problem Solving with Java

Being An Acrobat: Linux and PDFs. Presentation to Linux Users of Victoria. Melbourne, June 16,

Running Splunk Enterprise within Docker

Testing, Debugging, Program Verification

Signals Documentation

Guzzle Release Jun 02, 2017

PowerShell-Module Documentation. Release docs

CMSilex Documentation

I hate money. Release 1.0

Git Introduction CS 400. February 11, 2018

School of Computing Science Gitlab Platform - User Notes

LabCollector Web Service API

Tolerance Documentation

Drupal & Composer Matthew Grasmick & Jeff Geerling

Drupal 7 - Symfony - Dependency Injection Documentation

Guzzle Release November 14, 2017

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. Version Control

7/2/2013 R packaging with Rstudio Topics:

(Frequently Asked Questions)

trevor.bramwell.net Documentation

b. Developing multiple versions of a software project in parallel

swiftenv Documentation

WhereScape RED Installation

Visualizing Git Workflows. A visual guide to 539 workflows

Jexus Web Server Documentation

INSTALLATION GUIDE. for Magento 2 Extension

NetBackup Self Service Release Notes

PDF and Accessibility

Pieces of the API Puzzle: Leveraging Typed Data in Drupal 8

DOWNLOAD OR READ : HOW TO WIN AT SPREAD BETTING AN ANALYSIS OF WHY SOME PEOPLE WIN SOME LOSE AND HOW YOU CAN BE A WINNER PDF EBOOK EPUB MOBI

OTX to MISP. Release 1.4.2

Software Engineering

GreenPoint Design Simulation Tool

ADOBE WORD DOCUMENT harpending.org ADOBE WORD DOCUMENT. page 1 / 5

Low level CAN binding

How to contribute to Symfony for Symfony 2.0

CS313D: ADVANCED PROGRAMMING LANGUAGE

Ascent 7.0 Release Script for IBM Content Manager for iseries Release Notes

ag.el Documentation Release 0.45 Wilfred Hughes

CS 61B Data Structures and Programming Methodology. July 7, 2008 David Sun

Exception Handling. Exception Handling

Bitnami TestLink for Huawei Enterprise Cloud

Brewmeister Documentation

devops with

Transcription:

PHP XPDF Documentation Release 0.1 Romain Neutron - Alchemy February 02, 2017

Contents 1 Introduction 1 2 Installation 3 3 PDF2Text 5 3.1 Basic Usage............................................... 5 3.2 Using Custom Binary.......................................... 5 3.3 Charset encoding............................................. 6 3.4 Extract page range............................................ 6 3.5 Silex Service Provider.......................................... 6 4 Handling Exceptions 7 5 Report a bug 9 6 Ask for a feature 11 7 Contribute 13 8 Run tests 15 9 About 17 10 License 19 i

ii

CHAPTER 1 Introduction PHP-XPDF is an object oriented library to handle XPDF, an open source project self-described as a viewer for Portable Document Format files. The Xpdf project also includes a PDF text extractor, PDF-to-PostScript converter, and various other utilities. For the moment, there s only one handler for PDF2Text. This library depends on Symfony Process Component and Monolog. 1

PHP XPDF Documentation, Release 0.1 2 Chapter 1. Introduction

CHAPTER 2 Installation PHP-XPDF relies on composer. If you do not yet use composer for your project, you can start with this composer.json at the root of your project: { } "require": { "php-xpdf/php-xpdf": "master" } Install composer : # Install composer curl -s http://getcomposer.org/installer php # Upgrade your install php composer.phar install You now just have to autoload the library to use it : <?php require 'vendor/autoload.php'; This is a very short intro to composer. If you ever experience an issue or want to know more about composer, you will find help on its dedicated website http://getcomposer.org/. 3

PHP XPDF Documentation, Release 0.1 4 Chapter 2. Installation

CHAPTER 3 PDF2Text 3.1 Basic Usage <?php use Monolog\Logger; use Monolog\Handler\NullHandler; use XPDF\PdfToText; // Create a logger $logger = new Logger('MyLogger'); $logger->pushhandler(new NullHandler()); // You have to pass a Monolog logger // This logger provides some usefull infos about what's happening $pdftotext = PdfToText::load($logger); // open PDF $pdftotext->open('pdf-book.pdf'); // PDF text is now in the $text variable $text = $pdftotext->gettext(); $pdftotext->close(); 3.2 Using Custom Binary The PDF2Text is automatically detected if its path install is in the PATH. if you want to use your own PdfTotext binary, use as follow : <?php $pdftotext = new PdfToText('/path/to/your/binary', $logger); or, on Windows platform : <?php $pdftotext = new PdfToText('C:\XPDF\PDF2Text.exe', $logger); 5

PHP XPDF Documentation, Release 0.1 3.3 Charset encoding By default, output text is UTF-8 encoded. But if you want a custom output, use the setoutputencoding method <?php $pdftotext->setoutputencoding('iso-8859-5'); Note: The charset value should be an iconv compatible value. 3.4 Extract page range You can restrict the text extraction on page range. For example to extract pages 3 to 6 ; <?php $pdftotext->gettext(3, 6); 3.5 Silex Service Provider XPDF is bundled with a Silex Service Provider. Use it is very simple : <?php use Silex\Application; use XPDF\XPDFServiceProvider; $app = new Application(); $app->register(new XPDFServiceProvider()); // You have access to PDF2Text $app['xpdf.pdf2text']->open(...); You can, of course, customize it : <?php use Silex\Application; use XPDF\XPDFServiceProvider; $app = new Application(); $app->register(new XPDFServiceProvider(), array( 'xpdf.pdf2text.binary' => '/your/custom/binary', 'xpdf.logger' => $my_logger, )); // You have access to PDF2Text $app['xpdf.pdf2text']->open(...); 6 Chapter 3. PDF2Text

CHAPTER 4 Handling Exceptions XPDF throws 4 different types of exception : \XPDF\Exception\BinaryNotFoundException is thrown when no acceptable pdf2text binary is found. \XPDF\Exception\InvalidFileArgumentException is thrown when an invalid file is supplied for text extraction \XPDF\Exception\LogicException which extends SPL LogicException \XPDF\Exception\RuntimeException which extends SPL RuntimeException All these Exception implements \XPDF\Exception\Exception so you can catch any of these exceptions by catching this exception interface. 7

PHP XPDF Documentation, Release 0.1 8 Chapter 4. Handling Exceptions

CHAPTER 5 Report a bug If you experience an issue, please report it in our issue tracker. Before reporting an issue, please be sure that it is not already reported by browsing open issues. When reporting, please give us information to reproduce it by giving your platform (Linux / MacOS / Windows) and its version, the version of PHP you use (the output of php --version), and the version of xpdf you use (the output of xpdf -v). 9

PHP XPDF Documentation, Release 0.1 10 Chapter 5. Report a bug

CHAPTER 6 Ask for a feature We would be glad you ask for a feature! Feel free to add a feature request in the issues manager on GitHub! 11

PHP XPDF Documentation, Release 0.1 12 Chapter 6. Ask for a feature

CHAPTER 7 Contribute You find a bug and resolved it? You added a feature and want to share? You found a typo in this doc and fixed it? Feel free to send a Pull Request on GitHub, we will be glad to merge your code. 13

PHP XPDF Documentation, Release 0.1 14 Chapter 7. Contribute

CHAPTER 8 Run tests PHP-XPDF relies on PHPUnit for unit tests. To run tests on your system, ensure you have PHPUnit installed, and, at the root of PHP-XPDF, execute it : phpunit 15

PHP XPDF Documentation, Release 0.1 16 Chapter 8. Run tests

CHAPTER 9 About PHP-XPDF has been written by Romain Neutron @ Alchemy for Phraseanet, our DAM software. Try it, it s awesome! 17

PHP XPDF Documentation, Release 0.1 18 Chapter 9. About

CHAPTER 10 License PHP-XPDF is licensed under the MIT License 19