label->idf relationship, note that this means that labels can be used only once
$this->destinations["$label"] = $id;
}
/**
* define font families, this is used to initialize the font families for the default fonts
* and for the user to add new ones for their fonts. The default bahavious can be overridden should
* that be desired.
*
* @param $family
* @param string $options
*/
function setFontFamily($family, $options = '')
{
if (!is_array($options)) {
if ($family === 'init') {
// set the known family groups
// these font families will be used to enable bold and italic markers to be included
// within text streams. html forms will be used...
$this->fontFamilies['Helvetica.afm'] =
[
'b' => 'Helvetica-Bold.afm',
'i' => 'Helvetica-Oblique.afm',
'bi' => 'Helvetica-BoldOblique.afm',
'ib' => 'Helvetica-BoldOblique.afm'
];
$this->fontFamilies['Courier.afm'] =
[
'b' => 'Courier-Bold.afm',
'i' => 'Courier-Oblique.afm',
'bi' => 'Courier-BoldOblique.afm',
'ib' => 'Courier-BoldOblique.afm'
];
$this->fontFamilies['Times-Roman.afm'] =
[
'b' => 'Times-Bold.afm',
'i' => 'Times-Italic.afm',
'bi' => 'Times-BoldItalic.afm',
'ib' => 'Times-BoldItalic.afm'
];
}
} else {
// the user is trying to set a font family
// note that this can also be used to set the base ones to something else
if (mb_strlen($family)) {
$this->fontFamilies[$family] = $options;
}
}
}
/**
* used to add messages for use in debugging
*
* @param $message
*/
function addMessage($message)
{
$this->messages .= $message . "\n";
}
/**
* a few functions which should allow the document to be treated transactionally.
*
* @param $action
*/
function transaction($action)
{
switch ($action) {
case 'start':
// store all the data away into the checkpoint variable
$data = get_object_vars($this);
$this->checkpoint = $data;
unset($data);
break;
case 'commit':
if (is_array($this->checkpoint) && isset($this->checkpoint['checkpoint'])) {
$tmp = $this->checkpoint['checkpoint'];
$this->checkpoint = $tmp;
unset($tmp);
} else {
$this->checkpoint = '';
}
break;
case 'rewind':
// do not destroy the current checkpoint, but move us back to the state then, so that we can try again
if (is_array($this->checkpoint)) {
// can only abort if were inside a checkpoint
$tmp = $this->checkpoint;
foreach ($tmp as $k => $v) {
if ($k !== 'checkpoint') {
$this->$k = $v;
}
}
unset($tmp);
}
break;
case 'abort':
if (is_array($this->checkpoint)) {
// can only abort if were inside a checkpoint
$tmp = $this->checkpoint;
foreach ($tmp as $k => $v) {
$this->$k = $v;
}
unset($tmp);
}
break;
}
}
}