dev-master
9999999-dev https://github.com/markushausammann/princePhpA better PHP wrapper for the awesome PrinceXML PDF creator.
unlincense
The Requires
- php >=5.3.0
php pdf xhtml princexml
Wallogit.com
2017 © Pedro Peláez
A better PHP wrapper for the awesome PrinceXML PDF creator.
This package has not been officially released yet. Use at your own risk., (*1)
This wrapper is PSR-4 autoloading compliant and can be installed via composer. Add the following to your composer.json., (*2)
"require": {
"markushausammann/prince-php": "dev-master"
}
In the official library, the exePath is injected into the constructor, but that makes automatic injection of the prince
service harder. Instead use the respective setter., (*3)
$prince = new Prince();
$prince->setExePath('/your/bin/path');
Please note that the default path is /usr/local/bin/prince. So you have the option of just making sure
the binary of a symlink is in that location if you're running Prince on Linux., (*4)
On Windows, be sure to specify the path to the prince.exe file located within the Engine\bin subfolder of the Prince installation., (*5)
There are different combination of sources and end products, the (x)html markup can be provided as string or file and can be returned as file or stream., (*6)
convertFileToFileconvertMultipleFilesconvertStringToFileconvertFileToPassthruconvertMultipleFilesToPassthruconvertStringToPassthruaddStyleSheetclearStyleSheetsaddScriptclearScriptsaddFileAttachmentclearFileAttachmentssetLicenseFilesetLicenseKeysetInputTypesetHTMLsetJavaScriptsetLogsetBaseURLsetXIncludesetHttpUsersetHttpPasswordsetHttpProxysetInsecuresetFileRootsetEmbedFontssetSubsetFontssetArtificialFontssetCompresssetPDFTitlesetPDFSubjectsetPDFAuthorsetPDFKeywordssetPDFCreatorsetEncryptsetEncryptInfopublic function convertFileToFile($xmlPath, $pdfPath = '', &$messages = array())
Convert an XML or HTML file to a PDF file. Returns true if a PDF file was generated successfully., (*8)
public function convertMultipleFiles($xmlPaths, $pdfPath = '', &$messages = array())
Convert multiple XML or HTML files to a PDF file. Returns true if a PDF file was generated successfully., (*10)
public function convertStringToFile($xmlString, $pdfPath = '', &$messages = array())
Convert an XML or HTML string to a PDF file. Returns true if a PDF file was generated successfully., (*12)
public function convertFileToPassthru($xmlPath)
Convert an XML or HTML file to a PDF file, which will be passed through to the output buffer of the current PHP page. Returns true if a PDF file was generated successfully., (*14)
Currently there is no mechanism to retrieve error/warning messages when using this convert method. However, thesetLog function can be used to direct messages to an external file., (*15)
Note that to have the browser correctly display the PDF output, the following two lines will be needed before the convert method is called:, (*16)
header('Content-Type: application/pdf')
header('Content-Disposition: inline; filename="foo.pdf"');`
You may also specify attachment for the Content-Disposition header instead of inline, so that the browser will prompt the user to save the PDF file instead of displaying it., (*17)
public function convertMultipleFilesToPassthru($xmlPaths)
Convert multiple XML or HTML files to a PDF file, which will be passed through to the output buffer of the current PHP page. Returns true if a PDF file was generated successfully., (*19)
Currently there is no mechanism to retrieve error/warning messages when using this convert method. However, thesetLog function can be used to direct messages to an external file., (*20)
Note that to have the browser correctly display the PDF output, the following two lines will be needed before the convert method is called:, (*21)
header('Content-Type: application/pdf')
header('Content-Disposition: inline; filename="foo.pdf"');`
You may also specify attachment for the Content-Disposition header instead of inline, so that the browser will prompt the user to save the PDF file instead of displaying it., (*22)
public function convertStringToPassthru($xmlString)
Convert an XML or HTML string to a PDF file, which will be passed through to the output buffer of the current PHP page. Returns true if a PDF file was generated successfully., (*24)
Currently there is no mechanism to retrieve error/warning messages when using this convert method. However, thesetLog function can be used to direct messages to an external file., (*25)
Note that to have the browser correctly display the PDF output, the following two lines will be needed before the convert method is called:, (*26)
header('Content-Type: application/pdf')
header('Content-Disposition: inline; filename="foo.pdf"');`
You may also specify attachment for the Content-Disposition header instead of inline, so that the browser will prompt the user to save the PDF file instead of displaying it., (*27)
public function addStyleSheet($cssPath)
Add a CSS style sheet that will be applied to each input document. TheaddStyleSheet function can be called more than once to add multiple style sheets. This function can called before calling a convert function., (*29)
public function clearStyleSheets()
Clear all of the CSS style sheets accumulated by callingaddStyleSheet., (*31)
public function addScript($jsPath)
Add a JavaScript script that will be run before conversion. TheaddScript function can be called more than once to add multiple scripts. This function can be called before calling a convert function., (*33)
public function clearScripts()
Clear all of the scripts accumulated by callingaddScript., (*35)
public function addFileAttachment($filePath)
Add a file attachment that will be attached to the PDF file. TheaddFileAttachment can be called more than once to add multiple file attachments., (*37)
public function clearFileAttachments()
Clear all of the file attachments accumulated by callingaddFileAttachment., (*39)
public function setLicenseFile($file)
Specify the license file., (*41)
public function setLicenseKey($key)
Specify the license key., (*43)
public function setInputType($inputType)
Specify the input type of the document., (*45)
public function setHTML($html)
Specify whether documents should be parsed as HTML or XML/XHTML., (*47)
public function setJavaScript($js)
Specify whether JavaScript found in documents should be run., (*49)
public function setLog($logFile)
Specify a file that Prince should use to log error/warning messages., (*51)
public function setBaseURL($baseURL)
Specify the base URL of the input document., (*53)
public function setXInclude($xinclude)
Specify whether XML Inclusions (XInclude) processing should be applied to input documents. XInclude processing will be performed by default unless explicitly disabled., (*55)
public function setHttpUser($user)
Specify a username to use when fetching remote resources over HTTP., (*57)
public function setHttpPassword($password)
Specify a password to use when fetching remote resources over HTTP., (*59)
public function setHttpProxy($proxy)
Specify the URL for the HTTP proxy server, if needed., (*61)
public function setInsecure($insecure)
Specify whether to disable SSL verification., (*63)
, (*64)
A better PHP wrapper for the awesome PrinceXML PDF creator.
unlincense
php pdf xhtml princexml