PDF documents manipulation methods
package |
Default |
---|
compressDocument(string $pdftkPath, string $pdfPath, string $outputPath = '') : boolean
VERY IMPORTANT:
string
Full executable path to the pdftk tool. For example: $fileStorageManager->binaryGetAppPath('pdftk')
string
Full path to the pdf source file. Example: ProjectPaths::RESOURCES.'/pdf/mypdf.pdf'
string
Leave it empty (default value) to override the source pdf document or specify a full system path (including the destination filename) where the compressed result will be stored.
boolean
True if compression was performed or false if something failed
extractDocumentText(string $pdfPath) : string
string
Full path to the pdf source file. Example: ProjectPaths::RESOURCES.'/pdf/mypdf.pdf'
string
All the text that could be extracted from the pdf
generateDocumentJpgPictures(string $ghostScriptPath, string $pdfPath, string $outputPath, \org\turbocommons\src\main\php\utils\number $jpgQuality = 90, string $dpi = '200', string $outFileMask = '/%d.jpg') : \org\turbocommons\src\main\php\utils\number
Requires GhostScript, that is an open source library to manipulate PS and PDF files, that normally comes bundled with linux distributions. If not available, we must install it on our machine, or better download (http://www.ghostscript.com/download/gsdnld.html) the pre compiled binaries and place it on storage/binary
string
Full executable path to the ghostscript tool. For example: 'gs' if we are using the version installed on our machine or $fileStorageManager->binaryGetAppPath('gs') if we have placed it on our storage binary folder. It is recommended to user always the latest version, so we better download it and place it on storage/binary
string
Full path to the pdf source file. Example: ProjectPaths::RESOURCES.'/pdf/mypdf.pdf'
string
Full path to a file system EMPTY folder where all the generated pictures will be stored. If the specified folder is not empty or does not exist, an exception will happen.
\org\turbocommons\src\main\php\utils\number
90 by default. Specifies the jpg quality for all the generated pictures
string
200 by default, defines the pixel density for all the generated pictures. This will in fact affect the final resolution of the images.
string
'/%d.jpg' by default. Allows us to define a pattern for the generated file names (%d will be replaced by the page number). Example: '%05d.jpg' will generate a jpg file with 5 digits, like '00012.jpg'. More info on the GostScript manual for the option -o
\org\turbocommons\src\main\php\utils\number
The total number of generated pages or -1 if an error happened
generatePageJpgPicture(string $ghostScriptPath, string $pdfPath, string $page, \org\turbocommons\src\main\php\utils\number $jpgQuality = 90, string $dpi = '200') : string
Requires GhostScript, that is an open source library to manipulate PS and PDF files, that normally comes bundled with linux distributions. If not available, we must install it on our machine, or better download (http://www.ghostscript.com/download/gsdnld.html) the pre compiled binaries and place it on storage/binary
string
Full executable path to the ghostscript tool. For example: 'gs' if we are using the version installed on our machine or $fileStorageManager->binaryGetAppPath('gs') if we have placed it on our storage binary folder. It is recommended to user always the latest version, so we better download it and place it on storage/binary
string
Full path to the pdf source file. Example: ProjectPaths::RESOURCES.'/pdf/mypdf.pdf'
string
The number of the page we want to convert to a picture. FIRST PAGE STARTS AT 0
\org\turbocommons\src\main\php\utils\number
90 by default. Specifies the jpg quality for the generated picture
string
200 by default, defines the pixel density for the generated picture. This will in fact affect the final resolution of the image.
string
A binary string containing the generated picture, or null if some problem happened
getPagesCount(string $pdfInfoPath, string $pdfPath) : integer
This method requires an external command line tool called pdfinfo, that we should place on our project storage/binary folder Its free and can be downloaded from: http://www.foolabs.com/xpdf/download.html
VERY IMPORTANT:
string
Full executable path to the pdfInfo tool. For example: $fileStorageManager->binaryGetAppPath('pdfinfo')
string
Full path to the pdf source file. Example: ProjectPaths::RESOURCES.'/pdf/mypdf.pdf'
integer
The total number of calculated pages