PHP code example of ncjoes / pdf-suite

1. Go to this page and download the library: Download ncjoes/pdf-suite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ncjoes / pdf-suite example snippets



// if you are using composer, just use this
use NcJoes\PdfSuite\PdfSuite;
use NcJoes\PdfSuite\Config;

//Configuration
    Config::setBinDirectory(__DIR__.'/../vendor/bin/poppler');//set up poppler binaries location
    Config::setOutputDirectory(__DIR__.'/results', true); //set main output directory
    Config::doCleanupOnExit(false); //set to true if you want output files to be deleted on script termination


// Create PdfSuite instance
$file = dirname(__FILE__).'\sources\test1.pdf';
$pdfSuite = new PdfSuite($file);

//Pdf metadata
    $pdf_info = $pdfSuite->getPdfInfo(); //returns an associative array
    $authors = $pdf_info->getAuthors();
    $number_of_pages = $pdf_info->getNumOfPages();
    //...e.t.c.

//PDF to HTML converter
    $htmlConverter = $pdfSuite->getPdfToHtmlConverter();
    
    $htmlConverter->setPageRange(1, 16)->useDefaultSettings();
    $htmlConverter->setOutputSubDir('testSinglePageConverterOption');
    
    // returns a directory instance, a OOP model of a directory/folder containing the output files
    $directory = $htmlConverter->convert($htmlConverter::MODE_SINGLE_PAGE_PER_DOC);
    //other output mode options r svgConverter
    $svgConverterUtil->setOption('key', 'value');
    //etc
bash
NcJoes\PdfSuite\Config::setBinDirectory($dir);