Files
votianng/html/include/inc_pdf.inc.php
2026-03-29 10:34:57 +02:00

117 lines
3.9 KiB
PHP

<?php
/*=======================================================================
*
* inc_pdf.inc.php
*
=======================================================================*/
// Get the licence key of the PDF generator
function getLicenceKey () {
global $phpVer56Plus, $phpVersion;
if ($phpVersion >= "8.0") :
$licenceKey = getParameterValue("0", "LICENCE_PDFLIB_NEW", "0");
if ($licenceKey == "") :
$licenceKey = "LA00102-010045-037826-RYCW4P-ANC9RQ";
endif;
else :
if ($phpVersion >= "7.0") :
$licenceKey = getParameterValue("0", "LICENCE_PDFLIB_NEW", "0");
if ($licenceKey == "") :
$licenceKey = "L900102-010088-137725-RCVCD2-8434B2";
endif;
else :
if ($phpVer56Plus) :
$licenceKey = getParameterValue("0", "LICENCE_PDFLIB_NEW", "0");
if ($licenceKey == "") :
$licenceKey = "L900102-010033-137725-RBGZF2-MWYJH2";
endif;
else :
$licenceKey = getParameterValue("0", "LICENCE_PDFLIB", "0");
if ($licenceKey == "") :
$licenceKey = "L700102-010000-113168-RCXTG2-BWCT82";
endif;
endif;
endif;
endif;
return $licenceKey;
}
// Declare PDF File, get PDF object
function getPDFObject ($licenceKey) {
global $pdf;
// $pdf = PDF_new();
$pdf = new PDFlib();
// PDF_set_parameter($pdf, "license", $licenceKey);
$pdf->set_option("license=" . $licenceKey);
}
function setPDFParameter () {
global $pdf;
$dirName = dirname(__FILE__);
$dirName = str_replace("\\", "/", $dirName);
$lastSlashPos = strrpos($dirName,"/");
$path = substr($dirName, 0, $lastSlashPos);
// PDF_set_parameter($pdf, "FontOutline", "Courier New=" . $path . "/jobs/cour.ttf");
// $pdf->set_option("FontOutline={Courier New " . $path . "/jobs/cour.ttf}");
$pdf->set_option("FontOutline={Arial " . $path . "/include/arial.ttf}");
}
// Set PDF informations
function setPDFInfo ($title) {
global $pdf;
/*
PDF_set_info($pdf, "Author", "votian");
PDF_set_info($pdf, "Title", $title);
PDF_set_info($pdf, "Creator", "votian");
PDF_set_info($pdf, "Subject", $title);
*/
$pdf->set_info("Author", "votian");
$pdf->set_info("Title", $title);
$pdf->set_info("Creator", "votian");
$pdf->set_info("Subject", $title);
}
function closePDFObject ($filename) {
global $pdf;
// PDF_end_document($pdf, "");
$pdf->end_document("");
// $output = PDF_get_buffer($pdf);
$output = $pdf->get_buffer();
header("Content-type: application/pdf"); //set filetype to pdf.
header("Content-Length: ".strlen($output) + 2); //content length
header("Content-Disposition: attachment; filename=" . $filename . ".pdf"); // you can use inline or attachment.
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $output; // Current print area!
}
function closePDFObjectAsFile ($filename) {
global $pdf;
// PDF_end_document($pdf, "");
$pdf->end_document("");
// $output = PDF_get_buffer($pdf);
$output = $pdf->get_buffer();
$fileHandle = fopen("../temp/pdf/" . $filename, 'a');
fwrite($fileHandle, $output);
fclose($fileHandle);
}
function pdfNewPage ($pdfCurrentPositionYNew = "") {
global $pdf, $job_id, $pdfPageWidth, $pdfPageHeight, $font, $pdfCurrentPositionY;
// PDF_begin_page_ext($pdf, $pdfPageWidth, $pdfPageHeight, "");
$pdf->begin_page_ext($pdfPageWidth, $pdfPageHeight, "");
// PDF_setfont($pdf, $font, 12);
$pdf->setfont($font, 12);
$pdfCurrentPositionY = $pdfPageHeight - 35;
// PDF_show_xy($pdf, "Auftrag : " . $job_id, 15, $pdfCurrentPositionY);
$pdf->show_xy("Auftrag : " . $job_id, 15, $pdfCurrentPositionY);
// PDF_setfont($pdf, $font, 8);
$pdf->setfont($font, 8);
if ($pdfCurrentPositionYNew != "" && is_numeric($pdfCurrentPositionYNew)) :
$pdfCurrentPositionY = $pdfCurrentPositionYNew;
endif;
};
?>