From 387c2c08f6d5a0c1f70e3ce6f3b3ee95a2cb15f6 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Mon, 13 Jan 2025 10:49:01 +0100 Subject: [PATCH] bugfix auftrag PDF font list empty --- www/lib/dokumente/class.superfpdf.php | 1960 +++++++++++++------------ 1 file changed, 981 insertions(+), 979 deletions(-) diff --git a/www/lib/dokumente/class.superfpdf.php b/www/lib/dokumente/class.superfpdf.php index 89264f83..ebb2598e 100644 --- a/www/lib/dokumente/class.superfpdf.php +++ b/www/lib/dokumente/class.superfpdf.php @@ -1,982 +1,984 @@ - millimeter in 72 dpi -function px2mm($px){ - return $px*25.4/72; -} - -function txtentities($html){ - $trans = get_html_translation_table(HTML_ENTITIES); - $trans = array_flip($trans); - return strtr($html, $trans); -} - -class SuperFPDF extends PDF_EPS { - - /*********************************** - * user space functions - ***********************************/ - public $addpdf = null; - - function __construct($orientation='P',$unit='mm',$format='A4',$app=null){ - - if($app!=null) - $this->app=$app; - - $this->B=0; - $this->I=0; - $this->U=0; - $this->HREF=''; - $this->BeforeStack=array(); - - $this->number_ol=0; - parent::__construct($orientation,$unit,$format); - } - - public function AddPDF($file) - { - $filename = '/tmp/'.md5($file.microtime(true)).'.pdf'; - if($fp = fopen($filename, 'wb')) - { - fwrite($fp, $file); - fclose($fp); - if(file_exists($filename) && is_file($filename)){ - $this->addpdf[] = $filename; - return true; - } - } - return false; - } - - function displayAnhaenge($output='D') - { - //SuperFPDF::__construct('P','mm','A4'); - $this->seite_von_sichtbar = 1; - - // if($this->app->erp->Firmendaten("schriftart")!="") - // $this->SetFont($this->app->erp->Firmendaten("schriftart")); - - if($this->addpdf && is_array($this->addpdf) && count($this->addpdf) > 0) - { - - foreach($this->addpdf as $addpdf) - { - - $filename = $addpdf; - - $pn = $this->setSourceFile($filename); - //$this->AddPage(); - //$this->SetXY(0,0); - for($i = 1; $i <= $pn ; $i++) - { - $fn =& $this->current_filename; - $mediabox = $this->parsers[$fn]->getPageMediaBox($i); - //$this->app->erp->LogFile(addslashes(json_encode($mediabox))); - if($i >= 1) - { - //if(isset($mediabox['w']) && (float)$mediabox['w'] > 210.1 ) - if(isset($mediabox['w']) && (float)$mediabox['w'] > 216.0 ) - { - $this->AddPage('L'); - } else { - $this->AddPage(); - } - $this->SetXY(0,0); - } - $tplidx = $this->ImportPage($i); - $this->useTemplate($tplidx); - } - } - } - $result = $this->Output($this->filename,$output); - - if($output=="S") - return $result; - else - exit; - } - - - /*********************************** - * data aggregation functions - ***********************************/ - - /* - * general setter function - * - * proper usage: - * $field may be either a string or an array of strings - * if field is an array, $rdata must be an array(A) of associative arrays(B) with each of B representing a field - * if field is a string, $rdata must be an associative array - * - */ - public function setDocumentDetails($field, $rdata){ - if(is_array($field)) { - for($i=0;$i$field[$i] = $rdata[$i]; - } - } else $this->$field=$rdata; - } - - ////////////////////////////////////// - //html parser - - function WriteHtmlCell($cellWidth, $html){ - $rm = $this->rMargin; - $this->SetRightMargin($this->w - $this->GetX() - $cellWidth); - $this->WriteHtml($html); - $this->SetRightMargin($rm); - /* - // Alter Quelltext - $this->SetLeftMargin($cellWidth); - $this->WriteHtml($html); - $this->SetLeftMargin($cellWidth); - */ - } - - - function WriteHTML($html) - { - $x = $this->GetX(); - $this->SetLeftMargin($x); - - $allowed = array("ul","ol","li","b","u","i","a","img","p","br","strong","em","font","tr","blockquote","span"); //remove all unsupported tags - - //file_put_contents("/tmp/bene22",$html,FILE_APPEND); // wenn es wieder nicht passt prüfen warum - - /*$html = htmlspecialchars($html); - file_put_contents("/tmp/bene222",$html,FILE_APPEND); - - foreach( $allowed as $a ){ - $html = str_replace("<".$a.">", "<".$a.">", $html); - $html = str_replace("</".$a.">", "", $html); - $html = str_replace("<br />","
",$html); - } -*/ - - //file_put_contents("/tmp/bene222",$html,FILE_APPEND); - while(strpos($html ,'<<')!==false)$html = str_replace("<<", "<<", $html); - while(strpos($html ,'>>')!==false)$html = str_replace(">>", ">>", $html); - - $html = str_replace("<+", "<+", $html); // Fix: "<+/-2mm" wird ansonten von strip_tags() entfernt - $html = str_replace("<=", "<=", $html); // Fix: Kleinergleich wird ansonten von strip_tags() entfernt - $html = str_replace(" >=", " >=", $html); // Fix: Größergleich wird ansonten durch "> =" ersetzt - $html = str_replace("< ", "< ", $html); - $html = str_replace(" >", "> ", $html);//Leerzeichen umgedreht - $html=strip_tags($html, "