Gems standaard Pdf utility functions

package Gems
subpackage PDf
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.0
inherited_from \Gems_Registry_TargetAbstract

 Methods

Returns a callable if a method is called as a variable

__get(string $name) : Callable
Inherited

Parameters

$name

string

Returns

Callable

Called after the check that all required registry values have been set correctly has run.

afterRegistry() : void

Calls the PDF convertor (wkhtmltopdf / phantom.js) to convert HTML to PDF

convertFromHtml(string $content) : string

Parameters

$content

string

The HTML source

Exceptions

\Exception

Returns

stringThe converted PDF file

Reads the survey pdf and outputs the result (without token id's etc.

echoPdfBySurveyId($surveyId) 

.

Parameters

$surveyId

Reads the survey pdf belonging to this token, puts the token id on de pages and outputs the result.

echoPdfByTokenId(string $tokenId) 

Parameters

$tokenId

string

Output the pdf with the right headers.

echoPdfContent(string $content, string $filename, boolean $download = false

Parameters

$content

string

The content to echo

$filename

string

The filename as reported to the downloader

$download

boolean

Download to file or when false: show in browser

Returns (and optionally creates) the directory where the surveys are stored.

getSurveysDir() : string

Used by the Survey Controller when uploading surveys.

Returns

string

Return upload directory, optionally with specified sub directory.

getUploadDir(string $subdir = null) : string

You can overrule this function to specify your own directory.

Parameters

$subdir

string

Optional sub-directory, when starting with / or x:\ only $subdir is used. Function creates subdirectory if it does not exist.

Returns

string

hasPdfExport()

hasPdfExport() : boolean

Returns

boolean

Add the token to every page of a pdf

addTokenToDocument(\Zend_Pdf $pdf, string $tokenId, integer $surveyId) 

Parameters

$pdf

\Zend_Pdf

$tokenId

string

$surveyId

integer

Add the token to a pdf page

addTokenToPage(\Zend_Pdf_Page $page, string $tokenId) 

Parameters

$page

\Zend_Pdf_Page

$tokenId

string

Echos the pdf as output with the specified filename.

echoPdf(\Zend_Pdf $pdf, string $filename, boolean $download = false, boolean $exit = true

When download is true the file is returned as a download link, otherwise the pdf is shown in the browser.

Parameters

$pdf

\Zend_Pdf

$filename

string

$download

boolean

$exit

boolean

Should the application stop running after output

getSurveyPdf()

getSurveyPdf(integer $surveyId) : \Zend_Pdf

Parameters

$surveyId

integer

Returns

\Zend_Pdf

Rename existing file.

throwLastError($msg) : string

Parameters

$msg

Returns

string/ public function rename($source, $destination) { if (file_exists($source)) { $dir = dirname($destination); if (! is_dir($dir)) { $oldmask = umask(0777); if (! @mkdir($dir, 0777, true)) { $this->throwLastError("Could not create '$dir' directory."); } umask($oldmask); } if (file_exists($destination)) { if (! unlink($destination)) { $this->throwLastError("Could not remove existing '$destination' file."); } } if (! rename($source, $destination)) { $this->throwLastError("Could not rename '$source' to '$destination'."); } } else { $this->throwLastError("Source file '$source' does not exist."); } }

 Properties

 

$_pdfExportCommand

$_pdfExportCommand : string

Default

""
 

$db

$db : \Zend_Db_Adapter_Abstract

Default

 

Pdf font for token

$pageFont : string

Default

\Zend_Pdf_Font::FONT_COURIER
 

Font size for token

$pageFontSize : integer

Default

12
 

Horizontal position of token

$pageX : integer

Default

10
 

Is the horizontal position in pixel from left or right of page

$pageXfromLeft : boolean

Default

true
 

Vertical position of token

$pageY : integer

Default

20
 

Is the vertical position in pixel from top or bottom of page

$pageYfromTop : boolean

Default

true
 

$project

$project : \Gems_Project_ProjectSettings

Default

 

$translate

$translate : \Zend_Translate

Default