2017 © Pedro Peláez
 

library pdfexport

Collection of useful shorthand string related functions in PHP.

image

vielhuber/pdfexport

Collection of useful shorthand string related functions in PHP.

  • Tuesday, July 31, 2018
  • by vielhuber
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 29 Versions
  • 10 % Grown

The README.md

build status, (*1)

🍊 pdfexport 🍊

pdfexport exports pdfs., (*2)

Features

  • easy syntax
  • can merge/grayscale/fill pdfs
  • individual headers per page possible
  • very fast because of combining commands
  • overcomes command line / process limits
  • allows php code inside html templates
  • counts pages of pdfs
  • can set a limit on page counts
  • splits pdfs in chunks of size n
  • can create pdf/a files
  • can disallow printing and editing
  • stamp/watermark pdfs

Requirements

Installation

install once with composer:, (*3)

composer require vielhuber/pdfexport

then add this to your files:, (*4)

require __DIR__ . '/vendor/autoload.php';
use vielhuber\pdfexport\pdfexport;

you also can provide custom paths to underlying libs:, (*5)

$_ENV['PDFTK'] = 'C:\pdftk\bin\pdftk.exe';
$_ENV['WKHTMLTOPDF'] = 'C:\wkhtmltopdf\bin\wkhtmltopdf.exe';
$_ENV['GHOSTSCRIPT'] = 'C:\Program Files\GS\gs9.22\bin\gswin64c.exe';
$_ENV['IMAGEMAGICK'] = 'C:\Program Files\ImageMagick-6.9.9-Q16\convert.exe';
$_ENV['CPDF'] = 'C:\Program Files\cpdf\cpdf.exe';

in laravel just populate .env:, (*6)

PDFTK="C:\pdftk\bin\pdftk.exe"
WKHTMLTOPDF="C:\wkhtmltopdf\bin\wkhtmltopdf.exe"
GHOSTSCRIPT="C:\Program Files\GS\gs9.22\bin\gswin64c.exe"
IMAGEMAGICK="C:\Program Files\ImageMagick-6.9.9-Q16\convert.exe"
CPDF="C:\Program Files\cpdf\cpdf.exe"

and can overcome *nix limits by increasing the ulimit for open files:, (*7)

ulimit -n 999999

you can do this permanently inside /etc/security/limits.conf:, (*8)

* - nofile 999999

Usage

$pdf = new pdfexport;

// add a static pdf
$pdf->add('tests/file.pdf');

// add a static pdf and fill out the form
$pdf->add('tests/file.pdf')
    ->data([
        'placeholder1' => 'foo',
        'placeholder2' => 'bar'
    ]);

// add multiple portions of data
$pdf->add('tests/file.pdf')
    ->data([
        'placeholder1' => 'This is a test',
        'placeholder2' => 'This is a multiline\ntest1\ntest2\ntest3\ntest4\ntest5\ntest6\ntest7\ntest8\ntest9\ntest10'
    ])
    ->data([
        'placeholder3' => 'This is Sonderzeichen ß täst!'
    ]);

// form fields
$pdf->getFormFields('tests/file.pdf'); // [ ['name' => 'field_name_1', 'type' => 'Text'], ... ]
$pdf->hasFormField('tests/file.pdf', 'field_name_1') // true

// do the same but grayscale the page
$pdf->add('tests/file.pdf')
    ->grayscale();

// grayscale (not vector) with a resolution of 80%
$pdf->add('tests/file.pdf')
    ->grayscale(80);

// add a html file
$pdf->add('tests/file.html');

// add a html file in a3, landscape
$pdf->add('tests/file.html')
    ->format('a3','landscape');

// add a html file and replace placeholders (placeholder; ?>)
$pdf->add('tests/file.html')
    ->data([
        'placeholder1' => 'foo',
        'placeholder2' => 'bar'
    ]);

// add a html file with a header and footer with a height of 30mm (there also can be placeholders in the header/footer)
$pdf->add('tests/file.html')
    ->header('tests/header.html', 30)
    ->footer('tests/footer.html', 30)
    ->data([
        'placeholder1' => 'foo',
        'placeholder2' => 'bar'
    ]);

// strings are interpreted as html code
$pdf->add('<!DOCTYPE html><html><body>

body with placeholder1; ?>
</body></html>') ->header('<!DOCTYPE html><html><body>
header with placeholder2; ?>
</body></html>') ->footer('<!DOCTYPE html><html><body>
footer with placeholder3; ?>
</body></html>') ->data([ 'placeholder1' => 'foo', 'placeholder2' => 'bar', 'placeholder3' => 'baz' ]); // you can also execute php code inside templates $pdf->add('<!DOCTYPE html><html><body>
cur time:
</body></html>'); $pdf->add('<!DOCTYPE html><html><body>
another part:
</body></html>'); // the cool part is that this is also very performant (because this results only in only a few subcommands) foreach(range(0,2500) as $i) { $pdf->add('tests/file.html') ->header('tests/header.html', 30) ->footer('tests/footer.html', 30) ->data([ 'placeholder1' => 'foo', 'placeholder2' => 'bar' ]); } // put stamp on all pages $pdf->stamp('tests/watermark.pdf'); $pdf->download(); $pdf->download('tests/output.pdf'); $pdf->save('tests/output.pdf'); $pdf->base64(); $pdf->content(); $random_filename = $pdf->save(); $pdf->count($random_filename); // 42 $splitted_filenames = $pdf->split($random_filename, 7) // splits pdf in 6 chunks of size 7 $pdf->add('<!DOCTYPE html><html><body>
</body></html>') ->limit(2) ->save('tests/output.pdf'); $pdf->count('tests/output.pdf'); // 2; $pdf->add('<!DOCTYPE html><html><body>
</body></html>') ->setStandard('PDF/A') ->disablePermission(['print','edit']) ->save('tests/output.pdf'); $pdf->count('tests/output.pdf'); // 0 (no permission!)

The Versions

31/07 2018

dev-master

9999999-dev

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

31/07 2018

1.2.7

1.2.7.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

08/06 2018

1.2.6

1.2.6.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

13/04 2018

1.2.5

1.2.5.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

06/04 2018

1.2.4

1.2.4.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

06/04 2018

1.2.3

1.2.3.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

06/04 2018

1.2.2

1.2.2.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

06/04 2018

1.2.1

1.2.1.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

06/04 2018

1.2.0

1.2.0.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

03/04 2018

1.1.9

1.1.9.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.8

1.1.8.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.7

1.1.7.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.6

1.1.6.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.5

1.1.5.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.4

1.1.4.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.3

1.1.3.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.2

1.1.2.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.1

1.1.1.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.1.0

1.1.0.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.0.9

1.0.9.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.0.8

1.0.8.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.0.7

1.0.7.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

24/03 2018

1.0.6

1.0.6.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.5

1.0.5.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.4

1.0.4.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.3

1.0.3.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.2

1.0.2.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.1

1.0.1.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

23/03 2018

1.0.0

1.0.0.0

Collection of useful shorthand string related functions in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires