2017 © Pedro Peláez
 

library pdf-box

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

image

imal-h/pdf-box

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  • Wednesday, June 6, 2018
  • by imalhasaranga
  • Repository
  • 6 Watchers
  • 20 Stars
  • 10,915 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 18 Forks
  • 4 Open issues
  • 8 Versions
  • 6 % Grown

The README.md

PDFlib 1.3.0

PDFlib is a project which enables you to interact with PDFs, Current Release provide you methods to convert PDF to Images as well as Images to PDF, future releases will included more functions to interact with PDF files, (*1)

This project is an initiative of Treinetic (Pvt) Ltd, Sri Lanka. contact us via info@treinetic.com and get your project done by the experts., (*2)

Issues Software License Forks, (*3)

Requirements

You should have Ghostscript >= 9.16 installed and configured., (*4)

Install

The package can be installed via composer: ``` bash $ composer require imal-h/pdf-box, (*5)


## Usage Converting a PDF to set of images. ```php $pdflib = new ImalH\PDFLib\PDFLib(); $pdflib->setPdfPath($pdf_file_path); $pdflib->setOutputPath($folder_path_for_images); $pdflib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG); $pdflib->setDPI(300); $pdflib->setPageRange(1,$pdflib->getNumberOfPages()); $pdflib->setFilePrefix('page-'); // Optional $pdflib->convert();

Alternatively using chaining:, (*6)


$files = (new ImalH\PDFLib\PDFLib()) ->setPdfPath($pdf_file_path) ->setOutputPath($folder_path_for_images) ->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG) ->setDPI(300) ->setPageRange(1,$pdflib->getNumberOfPages()) ->setFilePrefix('page-') // Optional ->convert();

Making a PDF from set of images, (*7)


$pdflib = new ImalH\PDFLib\PDFLib(); $imagePaths = ["images-1.jpg","images-2.jpg"]; $pdflib->makePDF($destination_pdf_file_path,$imagePaths);

If in anycase code throws '**** Unable to open the initial device, quitting.' this type of error that means program can't create temporary files because of a permission problem, this error only comes in the Linux or Mac Oparating systems so Please check the apache log and provide necessay permissions, (*8)

Other useful methods

You can get the total number of pages in the pdf:, (*9)


$pdfBox->getNumberOfPages(); //returns the number of pages in the pdf $pdfBox->setPageRange(1,2); // allows you to convert only few pages in the PDF Document $pdfBox->setImageQuality(95); // allows you to tell the quality you expect in the output Jpg file (only jpg) $pdfBox->setDPI(300); //setting the DPI (Dots per inch) of output files $pdfLib->setImageFormat(\ImalH\PDFLib\PDFLib::$IMAGE_FORMAT_PNG,$dDownScaleFactor=null); //this will set the output image format, default it is jpg, but I recommend using pdf to png because it seems it is faster /* $dDownScaleFactor=integer This causes the internal rendering to be scaled down by the given (integer <= 8) factor before being output. For example, the following will produce a 200dpi output png from a 600dpi internal rendering: gs -sDEVICE=png16m -r600 -dDownScaleFactor=3 -o tiger.png\examples/tiger.png Read More : http://ghostscript.com/doc/current/Devices.htm */

Changelog

Please see CHANGELOG for more information what has changed recently., (*10)

Contributing

Please see CONTRIBUTING for details., (*11)

Tests

  • Make sure to run all the tests and see all of them are pssing before sumbitting a pull requests

How to run Tests ?

composer install
vendor/bin/phpunit

Credits

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions

06/06 2018

dev-master

9999999-dev https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

17/05 2018

1.2.2

1.2.2.0 https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

05/05 2018

1.2.1

1.2.1.0 https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

19/08 2017

1.2.0

1.2.0.0 https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

01/10 2016

1.1.2

1.1.2.0 https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

12/09 2016

1.1.1

1.1.1.0 https://github.com/imalhasaranga/PDFLib.git

Current Release of PDFlib provide you methods to convert PDF to Images as well as Images to PDF.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdflib for php

05/09 2016

1.1.0

1.1.0.0 https://github.com/imalhasaranga/PDFBox.git

PDFBox is Currently the fastest Php wrapper enables you to interact with PDFs, Current Release provide you methods to convert PDF to Images as well as Images to PDF, future releases will included more functions to interact with PDF files

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdfbox for php

05/09 2016

1.0.0

1.0.0.0 https://github.com/imalhasaranga/PDFBox.git

PDFBox is Currently the fastest Php wrapper enables you to interact with PDFs, Current Release provide you methods to convert PDF to Images as well as Images to PDF, future releases will included more functions to interact with PDF files

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

convert php wrapper ghostscript imal hasaranga pdf to images images to pdf pdfbox for php