@Nimja, thanks for the reply. I appreciate your efforts! I’ve removed Header and Footer Class code leaving me with this code;
<?php
/* MakePDF snippet:
v0.7 - Fixed the 'depcrecated' error that prevented PDFs from being proper.
v0.6 - Added multiple parents support.
v0.5 - Italic font support, limited to whole lines/paragraphs.
v0.4 - Optimizations for 100+ pages.
v0.3 - Added header and footer.
v0.2 - Numerous fixes
v0.1 - Basic work.
By Nimja - nimja.com
Usage:
[!MakePDF? &parent=`1` !] -- Basic example
[!MakePDF? &parent=`1,2,3` !] -- Multiple parents
[!MakePDF? &parent=`1` &sortBy=`pub_date` $sortDir=`asc` &where=`template=1` &filename=`Frozen_Youth.pdf` &limit=`10`!] -- Additional settings.
*/
/* ------------------------------------------
Basic settings
------------------------------------------- */
$parent = $_GET['documentid'];
if (isset($parent)) {
// &sortBY, field to sort by, defaults to pub_date.
$sortBy = (!empty($sortBy) ) ? $sortBy : 'menuindex';
// &sortHow, sort direction, defaults to ASC(ending).
// Options are: ASC, DESC
$sortHow = (!empty($sortHow) ) ? $sortHow : 'ASC';
//Additional 'filters'
$where = (!empty($where) ) ? $where : '';
//&filename - The filename of the PDF people will download.
$filename = (!empty($filename) ) ? $filename : 'Frozen_Youth.pdf';
//&limit - Max number of pages we will retrieve. Leave empty or 0 for all.
$limit = (!empty($limit) ) ? $limit : '';
//Fields we use.
$fields = 'longtitle,description,content';
$basepath = $modx->config['base_path']."assets/snippets/makepdf/";
$classpath = $basepath.'class/';
//Use MODX function to get documents
$parents = split(',', $parent);
$pages = Array();
foreach($parents as $par) {
$page = $modx->getDocument($par, $fields, 1, 0);
array_push($pages, $page);
}
/* ------------------------------------------
Start PDF and set the settings.
------------------------------------------- */
// initiate FPDI
$pdf = new PDF();
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile($basepath.'Page.pdf');
$pdf->SetAuthor('Nimja');
$pdf->SetCreator('Nimja');
$pdf->SetTitle('Frozen Youth');
// import page 1
$templatePage = $pdf->importPage(1);
// use the imported page and place it on the first page. After this it will be added to every page.
$pdf->useTemplate($templatePage);
// set the template to be applied automatically.
$pdf->setTemplate($templatePage);
$pdf->SetFont('Arial');
$pdf->SetTextColor(0,0,0);
$pdf->SetLineWidth(.25);
$pdf->SetDrawColor(0,0,0);
$pdf->SetMargins(10,10);
$newpage = false;
$remove = Array("\r", '<b>', '</b>');
$clean = Array('<i>', '</i>');
/* ------------------------------------------
Start content.
------------------------------------------- */
$c = 0;
$italic = false;
foreach ($pages as $page) {
//echo $page['longtitle'].' - '.$page['introtext'].'<br />';
$chapter = $page['longtitle'];
$title = $page['description'];
$content = str_replace($remove, '', $page['content']);
//Start at the top of a page after 10 chapters. Because I'm base-10 addicted.
if ($c > 9) {
$pdf->AddPage();
$c=0;
}
//Set the title.
$pdf->SetX(10);
$pdf->SetFont('Arial','',18);
$pdf->Cell(0,7,$chapter.' - '.$title,'B',1,'L');
//Add some space between the title and the content.
$pdf->Ln(3);
$content = split("\n", $content);
//Handle content per line/block.
foreach ($content as $par) {
$line = trim($par);
//Space between paragraphs (a little less than a whole line, looks nicer).
if (empty($line) ) {
$pdf->Ln(3);
} else {
if (strpos($line, '<i>') > -1) $italic = true;
//Switch between italic and normal. Only usable for whole paragraphs/lines for now.
if ($italic) {
$pdf->SetFont('Arial','i',11);
} else {
$pdf->SetFont('Arial','',11);
}
if (strpos($line, '</i>')) $italic = false;
$line = str_replace($clean, '', $line);
$pdf->MultiCell(0,4.5,$line,0,1,'L');
}
}
$pdf->Ln(10);
$italic = false;
$c++;
}
$pdf->Output('Frozen_Youth.pdf', 'd');
} else {
//Output error message because of missing parent ID
echo 'Parent ID missing!';
}
?>
but I’m getting:
Fatal error: Class ’PDF’ not found in /home/demolip/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 65