kristos80/piima

A, really, simple utility for working with PDF files

1.0.2 2021-05-12 11:39 UTC

This package is auto-updated.

Last update: 2024-04-12 18:07:34 UTC


README

Maintainability Rating Reliability Rating Security Rating Vulnerabilities Bugs CodeScene Code Health CodeScene System Mastery Codacy Badge

Piima

A, really, simple utility for working with PDF files.

For now it can do 2 distinct things (see public methods):

  1. Convert any page of a PDF file to an image
  2. Calculate the total pages of a PDF file

Dependencies

The package is dependent on ghostscript

Public methods

public static extractImage(string $pdf, string $image, int $page = 1, bool $silent = FALSE) : bool

// Creates an image from the first page of the pdf file 
// and returns `TRUE` or FALSE or throws an exception 
$thumbnailCreated = Piima::extractImage($pdf, $image);

// Creates an image from the 5th page of the pdf file 
// and returns `TRUE` or FALSE or throws an exception 
$thumbnailCreated = Piima::extractImage($pdf, $image, 5);

// Creates an image from the 5th page of the pdf file 
// and returns `TRUE` or `FALSE` without throwing an exception
$thumbnailCreated = Piima::extractImage($pdf, $image, 5, TRUE);

public static calculateTotalPages(string $pdf, bool $silent = FALSE): int

// Calculates total page of PDF file as an integer
// and returns it or throws an exception
Piima::calculateTotalPages($pdf);

// Calculates total page of PDF file as an integer
// and returns it without throwing an exception
Piima::calculateTotalPages($pdf, TRUE);