	function a4pdf_DB($bon_id, $testCall=false){
	require_once("config/connect.php");
	require_once("global_functions.php");
	require_once('include/extended_fpdf.php');

	global $qrImg_temp_dir, $errorCorrectionLevel, $matrixPointSize, $qrMargin;

	$A4TmplVersion="28"; # kp 29 12 2022

	$fontConfig=SCHRIFT_AUSDRUCK_PDF_A4;

	if ( strpos(strtolower($fontConfig), 'arial') !== false || strpos(strtolower($fontConfig), 'helvetica') !== false ||
	strpos(strtolower($fontConfig), 'sans serif') !== false ){ $pdfFont="Arial"; }

	else if ( strpos(strtolower($fontConfig), 'times') !== false || strpos(strtolower($fontConfig), 'roman') !== false ||
	(strpos(strtolower($fontConfig), 'serif') !== false && strpos(strtolower($fontConfig), 'sans') == false)) { $pdfFont="Times"; }
	else if (strpos(strtolower($fontConfig), 'courier') !== false ) { $pdfFont="Courier"; }
	else {$pdfFont="Arial"; }

	preg_match('/\d+px | \d+pt/', $fontConfig, $m);
	preg_match('/\d+/', $m[0], $match);
	$pdfFontSize=$match[0];

	$lineHeight=$pdfFontSize/2.5;


	$bonWidth=preg_replace('/[^\d]/', '', AUSDRUCK_GESAMTE_BREITE);
	$printer=mysql_fetch_array(mysql_query("SELECT win_drucker_name, drucker_margin_pdf, zoom_factor FROM drucker WHERE LOWER(ist_a4) = 'ja' "));
	$drucker=$printer[0];

	$margin=$printer[1];
	$margins=explode(",", $margin);

	if(isset($margins[2]))$marginLR=preg_replace('/\D/', '', $margins[2]); else $marginLR=0;
	if(isset($margins[1]))$marginBottom=preg_replace('/\D/', '', $margins[1]); else $marginBottom=0;
	if(isset($margins[0]))$marginTop=preg_replace('/\D/', '', $margins[0]); else $marginTop=0;

	if($marginLR < 10) $marginLR=10; if(is_int($printer[2]) || is_float($printer[2])) $zoomF=$printer[2]; else $zoomF=1; $pageWidth=210-($marginLR*2); $pdfPrinterData=$printer; $bonData=mysql_fetch_array(mysql_query("SELECT kunden_id, verkaufer_id, gesamt_summe, retourgeld, bon_erstellt_datum, storno_datum, gastro_tisch_id, qr_string , zusatztext FROM abgeschlossener_bon LEFT JOIN dep ON abgeschlossener_bon.bon_id=dep.beleg_nr WHERE bon_id=".$bon_id." "));
				if(!$bonData) $xx=mysql_error();
				
						
			class PDF extends PDF_MemImage{

				function Header() {
					$marginTop=$this->marginTop;
					$marginLR=$this->marginLR;
					$pdfFontSize=$this->pdfFontSize;
					$pdfFont=$this->pdfFont;
					$lineHeight=$this->lineHeight;
					$bonId=$this->bonId;
					$bonData=$this->bonData;
					
					$this->SetFont($pdfFont, '', $pdfFontSize);

					$calcH=0;
					if(defined('AUSDRUCK_A4_LOGO_POSITION') && AUSDRUCK_A4_LOGO_POSITION != "")$logoPos=AUSDRUCK_A4_LOGO_POSITION;
					else $logoPos='R, 50';	
					
					$logoPos=explode(',', $logoPos);
					if(isset($logoPos[0]) && $logoPos[0] != '')$logoPos[0]=$logoPos[0];
					else $logoPos[0] = 'R';
					if(isset($logoPos[1]) && $logoPos[1] > 20)$imgWidth=$logoPos[1];
					else $imgWidth = 50;
					
					if(strtolower($logoPos[0]) == 'r') $leftPos=210-($imgWidth+$marginLR);
					else if(strtolower($logoPos[0]) == 'l') $leftPos=$marginLR;
					else if(strtolower($logoPos[0]) == 'c') $leftPos=(210-$imgWidth)/2;	
					
					if(defined('AUSDRUCK_A4_ADRESS_POSITION') && AUSDRUCK_A4_ADRESS_POSITION != "")$adressPos=AUSDRUCK_A4_ADRESS_POSITION;
					else $adressPos='L, 30, R';
					
					$adressPos=explode(',', $adressPos);
					if(isset($adressPos[0]) && $adressPos[0] != '')$adressPos[0]=$adressPos[0];
					else $adressPos[0]= 'L';
					if(isset($adressPos[1]) && $adressPos[1] > 20)$adressCellWidth=$adressPos[1];
					else $adressCellWidth=100;
					if(isset($adressPos[2]) && $adressPos[2] != '')$adressPos[2]=$adressPos[2];
					else $adressPos[2]= 'L';

					if ($this->PageNo() == 1){
						$getImg=mysql_fetch_assoc(mysql_query(" SELECT image, name, imgx, imgy FROM images WHERE name='a4logo'"));
							if(defined('AUSDRUCK_LOGO_RECHNUNGSBON_PDF') && strtolower(AUSDRUCK_LOGO_RECHNUNGSBON_PDF) == 'ja' && $getImg != false){
								
								$zuzX=$this->GetY();
								if($getImg == true){
									
									$fac=$getImg['imgx']/$imgWidth;
									$calcH=$getImg['imgy']/$fac;
									
									$this->MemImage($getImg['image'], $leftPos, $marginTop, $imgWidth, 0);   // breite ist definiert höhe auf null heißt wird calkuliert
								}

								if( strtolower($logoPos[0]) == 'r' && strtolower($adressPos[0]) == 'r'){
									$this->SetXY($leftPos, $marginTop+$calcH);
									$curYpos=$this->GetY()+$lineHeight;
								
								}
								else $curYpos=$marginTop;
							}
							
							else {
								$curYpos=$marginTop;
								
							}
							
							$ibanTx="";
							$kopfQl=mysql_query(" SELECT name, wert FROM konfiguration WHERE name LIKE 'AUSRUCK_KOPFZEILE_%' AND wert <> '' ORDER BY name");

		while($kopfR=mysql_fetch_array($kopfQl)){

		$wert=$kopfR["wert"];
		if(strpos(strtolower($kopfR["wert"]), 'uid') !== false || $kopfR["name"] == 'AUSRUCK_KOPFZEILE_IBAN') continue;


		if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'r'){
		$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'R');
		}
		else if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'c'){
		$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
		}
		else if(strtolower(trim($adressPos[0])) == 'r' && strtolower(trim($adressPos[2])) == 'l'){
		$this->SetXY(210-($adressPos[1]+$marginLR), $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
		}
		else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'r'){
		$this->SetXY((210-$adressPos[1])/2, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'R');
		}
		else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'c'){
		$this->SetXY((210-$adressPos[1])/2, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
		}
		else if(strtolower(trim($adressPos[0])) == 'c' && strtolower(trim($adressPos[2])) == 'l'){
		$this->SetXY((210-$adressPos[1])/2, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
		}
		else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'r'){
		$this->SetXY($marginLR, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, strip_tags($kopfR['wert']), 0, 1, 'R');
		}
		else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'c'){
		$this->SetXY($marginLR, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'C');
		}
		else if(strtolower(trim($adressPos[0])) == 'l' && strtolower(trim($adressPos[2])) == 'l'){
		$this->SetXY($marginLR, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
		}

		else{
		$this->SetXY($marginLR, $curYpos);
		$this->Cell($adressCellWidth, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kopfR['wert'])), 0, 1, 'L');
		}

		$curYpos+=$lineHeight; # die Zellen sind absolut positioniert, deswegen muss hier die Y position immer um eine lineHeight erhöht werden


		}

		$kundenId=$bonData["kunden_id"];

		$this->SetY(65);

		if($kundenId > 0 ){
		$custData="";
		$kundenDetails=mysql_fetch_assoc(mysql_query("SELECT * FROM kunden WHERE id=".$kundenId." "));

		if(strlen($kundenDetails['anrede']) > 0) $anrede=$kundenDetails['anrede']." ";
		else $anrede="";
		if(strlen($kundenDetails['titel']) > 0) $titel=$kundenDetails['titel']." ";
		else $titel="";

		if(strlen($kundenDetails['vorname']) > 0 && strlen($kundenDetails['nachname']) > 0) $kdName=$kundenDetails['vorname']." ".$kundenDetails['nachname'];
		else if(strlen($kundenDetails['nachname']) > 0 &&
		(strlen($kundenDetails['vorname']) == 0 || $kundenDetails['vorname'] == false ))$kdName=$kundenDetails['nachname'];
		else if(strlen($kundenDetails['vorname']) > 0 &&
		(strlen($kundenDetails['nachname']) == 0 || $kundenDetails['nachname'] == false ))$kdName=$kundenDetails['vorname'];
		else $kdName="";

		$kdName=$anrede.$titel.$kdName;

		if(strlen($kundenDetails['Firma']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['Firma'])), 0, 1, 'L');
		if(strlen($kdName) > 0 )$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kdName)), 0, 1, 'L');
		if(strlen($kundenDetails['strasse1']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['strasse1'])), 0, 1, 'L');
		if(strlen($kundenDetails['strasse2']) > 0)$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['strasse2'])), 0, 1, 'L');
		if($kundenDetails['plz'] != '' || $kundenDetails['Ort'] != '')
		$this->Cell(0, $lineHeight, iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['plz']))." ".iconv('UTF-8', 'windows-1252', strip_tags($kundenDetails['Ort'])), 0, 1, 'L');

		$this->Cell(0, $lineHeight, "", 'B', 1, 'C'); # trennlinie unterhalb von Kunden Druck, falls Kunde ausgegeben wird
		}

		else {
		$zahlung=mysql_query("SELECT Name FROM abgeschlossener_bon_zahlung WHERE bon_id=".$bonId." ");
		while($zahlR=mysql_fetch_array($zahlung)){
		$zahlForm=$zahlR['Name'];
		}

		if(mysql_num_rows ($zahlung) > 1 ) $zahlForm="Gemischte Zahlungsform";

		$this->Cell(0, $lineHeight, $zahlForm." Verkauf", 0, 1, 'L');
		$this->Cell(0, $lineHeight, "", 0, 1, 'L');
		$this->Cell(0, $lineHeight, "", 0, 1, 'L');
		$this->Cell(0, $lineHeight, "", 0, 1, 'L');

		$this->Cell(0, $lineHeight, "", 'B', 1, 'C');

		}

		}

		else { # bei mehrseitigen ausdruck wird ab der zweiten seite ein reduzierter header gedruckt
		if(defined('AUSDRUCK_LOGO_RECHNUNGSBON_PDF') && strtolower(AUSDRUCK_LOGO_RECHNUNGSBON_PDF) == 'ja'){
		$getImg=mysql_fetch_assoc(mysql_query("SELECT image, name, imgx, imgy FROM images WHERE name='a4logo'"));

		if($getImg == true){

		$fac=$getImg['imgx']/$imgWidth;
		$calcH=$getImg['imgy']/$fac;
		$this->MemImage($getImg['image'], $leftPos, $marginTop, $imgWidth, 0); // breite ist definiert höe auf null heißt wird calkuliert
		}
		}

		$this->Ln($calcH+$marginTop+10);

		if($this->checkPageBreak == true && $this->produktWhileEnd == false){
		$pageWidth=210-($this->marginLR*2);
		$colA_width=($pageWidth*.12)*$this->zoomF;
		$colB_width=($pageWidth*.38)*$this->zoomF;
		$colC_width=($pageWidth*.25)*$this->zoomF;
		$colD_width=($pageWidth*.25)*$this->zoomF;

		$this->SetFillColor(90);
		$this->SetTextColor(255);

		$this->Cell($colA_width, $lineHeight*1.3, "Stk.", 0, 0, 'R', true);
		$this->Cell($colB_width, $lineHeight*1.3, "Bezeichnung", 0, 0, 'L', true);
		$this->Cell($colC_width, $lineHeight*1.3, "Einzel", 0, 0, 'R', true);
		$this->Cell($colD_width, $lineHeight*1.3, "Ges. Brutto", 0, 1, 'R', true);
		$this->Cell(0, $lineHeight/3, "", 0, 1, 'C');
		$this->SetFillColor(255);
		$this->SetTextColor(0);

		}

		}


		}

		function docData(){
		$marginLR=$this->marginLR;
		$pdfFontSize=$this->pdfFontSize;
		$pdfFont=$this->pdfFont;
		$lineHeight=$this->lineHeight;
		$bonId=$this->bonId;
		$bonData=$this->bonData;

		$invoiceSumRaw=$bonData["gesamt_summe"];
		$gesamtsumme_brutto=number_format($bonData["gesamt_summe"],2,",",".");
		$datetime=$bonData["bon_erstellt_datum"];
		$stornoDatetime=$bonData["storno_datum"];
		$retourgeld=$bonData["retourgeld"];

		$verkauferId=$bonData["verkaufer_id"];
		$gastroTischId=$bonData["gastro_tisch_id"];

		$this->SetFont($pdfFont, '', $pdfFontSize);
		$pageWidth=210-($marginLR*2);

		$dDate = strtotime( $datetime );
		$datetime = "Datum: ".date( 'j.n.Y H:i:s', $dDate );

		$this->Cell($pageWidth/2, $lineHeight*1.2, BELEG_BENENNUNG." ".$bonId, 0, 0, 'L');
		$this->Cell($pageWidth/2, $lineHeight*1.2, $datetime, 0, 1, 'R');

		if(defined("VERKAEUFER_AUF_BON_DRUCKEN") && strtolower(VERKAEUFER_AUF_BON_DRUCKEN)=='ja'){
		$userQl=mysql_fetch_array(mysql_query("SELECT name FROM benutzer WHERE id = ".$verkauferId." "));
		if($userQl==true) $this->Cell($pageWidth/2, $lineHeight*1.2, AUSDRUCK_VERKAUFER_AUF_BON_TEXT." ".iconv('UTF-8', 'windows-1252', $userQl[0]), 0, 0, 'L');
		}
		else $this->Cell($pageWidth/2, $lineHeight*1.2, "", 0, 0, 'L');




		$sql = "SELECT offener_bon.id, bon_id, name, pricesell, tax_rate, printname, stueck, kunden_id, has_childs, aus_ls_nr,
		bon_add_text.id AS bonTxtId, bon_text, abholschein_nr, beilagen_aenderung_minus, beilagen_aenderung_plus
		FROM offener_bon
		LEFT JOIN bon_add_text ON offenerbon_id = bon_id
		WHERE bon_id='" . $bon_id . "'";

		$addTxt = "";
		$addTxt = $row_produkt['bon_text'];
		$this->Cell($pageWidth, $lineHeight, $addTxt, 0, 0, 'L');





		$this->Cell($pageWidth/2, $lineHeight*1.2, iconv('UTF-8', 'windows-1252', "Beträge in EUR"), 0, 1, 'R');
		$this->Cell(0, $lineHeight*1.2, "", "T", 1, 'C');
		$this->MultiCell($pageWidth, $lineHeight*1.2, iconv('UTF-8', 'windows-1252', $bonData['zusatztext']), 0, 'C', 0);
		$this->Cell(0, $lineHeight*1.2, "", "T", 1, 'C');
		$colA_width=($pageWidth*.12)*$this->zoomF;
		$colB_width=($pageWidth*.38)*$this->zoomF;
		$colC_width=($pageWidth*.25)*$this->zoomF;
		$colD_width=($pageWidth*.25)*$this->zoomF;
		$this->SetFillColor(90);
		$this->SetTextColor(255);

		$this->Cell($colA_width, $lineHeight*1.3, "Stk.", 0, 0, 'R', true);
		$this->Cell($colB_width, $lineHeight*1.3, "Bezeichnung", 0, 0, 'L', true);
		$this->Cell($colC_width, $lineHeight*1.3, "Einzel", 0, 0, 'R', true);
		$this->Cell($colD_width, $lineHeight*1.3, "Ges. Brutto", 0, 1, 'R', true);
		$this->Cell(0, $lineHeight/3, "", 0, 1, 'C');
		$this->SetFillColor(255);
		$this->SetTextColor(0);


		$sql_produkte = mysql_query("SELECT ID, produkt_id, tax_rate, REFERENCE, CODE, NAME, PRICEBUY, PRICESELL, CATEGORY, TAXCAT, tax_rate, DISPLAY,
		VARPRICE, PRINTNAME, NEGATIVEPRICE, PRODUKTORDER, SICHTBAR, stueck, has_childs, parent_id, isparent_id, childPrint
		FROM abgeschlossener_bon_produkte WHERE bon_id='".$bonId."'");

		if (!$sql_produkte) {
		echo "<script>
			console.log('Datenbank Fehler: '
				".mysql_error().")
		</script>";
		exit(1);
		}

		$countRows=mysql_num_rows($sql_produkte)*1;
		$checkRows=0;
		$this->checkPageBreak=0;

		while ($row_produkt=mysql_fetch_assoc($sql_produkte)) {
		$einzel_preis=$row_produkt["PRICESELL"];
		$einzel_preis=$einzel_preis*(1+$row_produkt["tax_rate"]);
		$summe=$einzel_preis*$row_produkt["stueck"];
		$einzel_preis=number_format($einzel_preis,2,",",".");

		# COMBI ARTIKEL !!!
		if($row_produkt['has_childs'] == 1 && $row_produkt['isparent_id'] > 0){
		$findChilds=mysql_fetch_array(mysql_query("SELECT SUM(PRICESELL* (1 + tax_rate)) AS combiEinzelPr FROM abgeschlossener_bon_produkte
		WHERE parent_id = ".$row_produkt['ID']." "));

		$einzel_preis=number_format($findChilds['combiEinzelPr'],2,",",".");
		$summe=$findChilds['combiEinzelPr']*$row_produkt["stueck"];
		}
		else if($row_produkt['parent_id'] > 0 && $row_produkt['childPrint'] == 0) continue;


		$stueck=$row_produkt["stueck"];
		// Checke ob Stueck nachkomma hat oder nicht wenn ja, dann 2 Nachkommastellen ansonsten keine
		if ( (int) $stueck == $stueck) {
		$stueck_anzeige=number_format($stueck,0,"",".");
		}
		else $stueck_anzeige=number_format($stueck,2,",",".");

		$summe=number_format($summe,2,",",".");
		$printname=$row_produkt["PRINTNAME"];

		if($row_produkt['parent_id'] > 0 && $row_produkt['childPrint'] == 1){

		$ortstaxe=number_format($stueck*$row_produkt["PRICESELL"],2, ",", ".");
		$einzel_preis='';
		$stueck_anzeige='';
		$summe='';

		$printname=preg_replace('/€\s*0[,\.]00/', '€ '.$ortstaxe, $printname);
		}

		$this->Cell($colA_width, $lineHeight, $stueck_anzeige, 0, 0, 'R');


		if($this->getstringwidth(iconv('UTF-8', 'windows-1252', $printname)) > $colB_width){
		$posY=$this->GetY();
		$posX=($colA_width + $colB_width + $marginLR );
		$this->MultiCell( $colB_width, $lineHeight, iconv('UTF-8', 'windows-1252', $printname) , 0, 'L', 0); # border-0; align L, fill-0,
		$posY_2=$this->GetY();
		$this->SetXY($posX, $posY);

		$this->Cell($colC_width, $lineHeight, $einzel_preis, 0, 0, 'R');
		$this->Cell($colD_width, $lineHeight, $summe, 0, 1, 'R');
		$this->SetY($posY_2);
		}
		else{
		$this->Cell($colB_width, $lineHeight, iconv('UTF-8', 'windows-1252', $printname), 0, 0, 'L');
		$this->Cell($colC_width, $lineHeight, $einzel_preis, 0, 0, 'R');
		$this->Cell($colD_width, $lineHeight, $summe, 0, 1, 'R');
		}

		$checkRows++;
		if($checkRows < $countRows) $this->checkPageBreak = true;
			else $this->checkPageBreak = false;

			}

			$this->produktWhileEnd=true;


			$this->Cell(0, $lineHeight/2, "", 0, 1, 'C', 0);
			$this->SetLineWidth(.5);
			$this->SetDrawColor(90);
			$this->SetFont($pdfFont,'B', $pdfFontSize);
			$this->Cell($colA_width + $colB_width, $lineHeight*1.2, "Rechnungssumme: ", "T", 0, 'L',0);

			$this->Cell($colC_width + $colD_width, $lineHeight*1.2, $gesamtsumme_brutto, "T", 1, 'R',0);
			$this->SetLineWidth(.2);
			$this->SetDrawColor(250, 250, 250);

			$this->SetFont($pdfFont,'', $pdfFontSize);
			$this->Cell(0, $lineHeight*1.5, "", 0, 1, 'C');

			$StColBlind_width=($pageWidth*.15)*$this->zoomF;
			$StColA_width=($pageWidth*.20)*$this->zoomF;
			$StColB_width=($pageWidth*.20)*$this->zoomF;
			$StColC_width=($pageWidth*.20)*$this->zoomF;
			$StColD_width=($pageWidth*.25)*$this->zoomF;


			$sql_tax = mysql_query("SELECT tax_rate, gesamt_betrag from abgeschlossener_bon_steuern WHERE bon_id='".$bonId."'");
			if (! $sql_produkte){
			echo "<script>
				console.log('Datenbank Fehler: '
					".mysql_error().")
			</script>";
			exit(1);
			}
			$qtyTaxRates=mysql_num_rows($sql_tax);
			$taxBlockHeight=($lineHeight*$qtyTaxRates)+$lineHeight;
			$currY=$this->GetY();
			$restOnPage=$currY+$taxBlockHeight+AUSDRUCK_A4_FOOTER_HOEHE;
			if($restOnPage > 275 ) $this->AddPage('','',false);

			$this->Cell($StColBlind_width, $lineHeight, "", 0, 0, 'R');
			$this->Cell($StColA_width, $lineHeight, "Steuersatz", 0, 0, 'R');
			$this->Cell($StColB_width, $lineHeight, "Netto", 0, 0, 'R');
			$this->Cell($StColC_width, $lineHeight, "Steuer", 0, 0, 'R');
			$this->Cell($StColD_width, $lineHeight, "Brutto", 0, 1, 'R');



			while ($rowTax=mysql_fetch_assoc($sql_tax)) {
			$steuersatz=$rowTax["tax_rate"]*100;
			$netto=$rowTax["gesamt_betrag"];
			$steuer=$netto*$rowTax["tax_rate"];
			$brutto=$netto+$steuer;
			$brutto=number_format($brutto,2,",",".");
			$netto=number_format($netto,2,",",".");
			$steuer=number_format($steuer,2,",",".");

			$this->Cell($StColBlind_width, $lineHeight, "", 0, 0, 'R');
			$this->Cell( $StColA_width, $lineHeight, $steuersatz, 0, 0, 'R');
			$this->Cell( $StColB_width, $lineHeight, $netto , 0, 0, 'R');
			$this->Cell( $StColC_width, $lineHeight, $steuer, 0, 0, 'R');
			$this->Cell( $StColD_width, $lineHeight, $brutto, 0, 1, 'R');

			}

			$qr_string=$bonData["qr_string"];

			if(strlen($qr_string) > 55){

			$qrX=explode("_", $qr_string);
			$lastIndex=count($qrX)-1;
			$sigData=base64_decode($qrX[$lastIndex]);
			if(strtolower($sigData) == 'sicherheitseinrichtung_ausgefallen' ){
			$this->Cell($pageWidth, $lineHeight*2, "", 0, 1, "C");
			$sigData=str_replace("_", " ", $sigData);
			$this->SetFont($pdfFont, 'B', $pdfFontSize);
			$this->Cell($pageWidth, $lineHeight, $sigData, 0, 1, "C");
			}
			else{
			$qrImgMarginTop=10;
			$qrImgMarginBottom=5;
			$qrImgSize=38;
			$qrImgPosL=(($pageWidth-$qrImgSize)/2)+$marginLR;

			$imgY=$this->GetY()+$qrImgMarginTop;

			$PageHeightNet=297-$this->marginTop-AUSDRUCK_A4_FOOTER_HOEHE;
			$refPos=$PageHeightNet-$imgY-$qrImgMarginBottom-$qrImgSize;

			if($refPos < 0 ){ $this->AddPage('','',false);
				$this->Cell(0, 1, '', 0, 1, 'C');
				$imgY=$this->GetY()+$qrImgMarginTop;
				}

				$qrFilename=$this->qrImg_temp_dir.$bonId.".png";


				QRcode::png($qr_string, $qrFilename, $this->errorCorrectionLevel, $this->matrixPointSize, $this->qrMargin);
				$this->Image($qrFilename, $qrImgPosL, $imgY, $qrImgSize, 'PNG');
				unlink($qrFilename);
				}

				}





				} # ende function docdata

				function Footer(){
				$this->SetY(-AUSDRUCK_A4_FOOTER_HOEHE);
				$this->SetFont($this->pdfFont, '', $this->pdfFontSize*.75);
				$footerTxt=AUSDRUCK_A4_FOOTER_TXT;
				$this->SetDrawColor(0);
				$this->Cell(0, 2, "", "T", 1, 'C');
				if (strpos($footerTxt, ';') !== false) {
				$footerLines=explode(";", $footerTxt);
				for($i=0; $i < sizeof($footerLines); $i++){ $this->Cell(0, $this->lineHeight, iconv('UTF-8', 'windows-1252', $footerLines[$i]), 0, 1, 'C');
					}
					}
					else {
					$this->Cell(0, $this->lineHeight, iconv('UTF-8', 'windows-1252', $footerTxt), 0, 1, 'C');
					}

					$this->Cell(0, $this->lineHeight, 'Seite '.$this->PageNo(). '/{nb}', 0, 1, 'R');
					}
					}


					$pdf=new PDF('P','mm', 'A4');
					$pdf->SetMargins($marginLR, $marginTop);



					$pdf->header = 0;
					$pdf->footer = 0;
					# $pdf->addPage('','',false);

					$pdf->pdfPrinterData=$pdfPrinterData;
					$pdf->marginTop=$marginTop;
					$pdf->marginLR=$marginLR;
					$pdf->pdfFont=$pdfFont;
					$pdf->pdfFontSize=$pdfFontSize;
					$pdf->lineHeight=$lineHeight;
					$pdf->bonId=$bon_id;
					$pdf->bonData=$bonData;
					$pdf->zoomF=$zoomF;
					$pdf->errorCorrectionLevel=$errorCorrectionLevel;
					$pdf->matrixPointSize=$matrixPointSize;
					$pdf->qrMargin=$qrMargin;
					$pdf->qrImg_temp_dir=$qrImg_temp_dir;
					$pdf->produktWhileEnd=false;

					$pdf->checkPageBreak=false;
					$pdf->SetAutoPageBreak(true, AUSDRUCK_A4_FOOTER_HOEHE+15);

					$pdf->AddPage('','',false);
					$pdf->docData();
					$pdf->AliasNbPages('{nb}');


					if(defined('AUSDRUCK_A4_DOWNLOAD') && strtolower(AUSDRUCK_A4_DOWNLOAD) == 'ja'){
					$outputTarget="docs/A4_bon_V".$A4TmplVersion."_".$bon_id."_".date('d_m_H_i').".pdf";
					$writeFile=$pdf->Output($outputTarget, "F");
					if($writeFile == ""){
					if($testCall == 'testCall') echo json_encode(array("success", "browserPrint", $outputTarget ));
					else return array("success", "browserPrint", $outputTarget );
					}
					else{
					if($testCall == 'testCall') echo json_encode(array("error", "browserPrint", $outputTarget ));
					else return array("error", "browserPrint", $outputTarget );
					}

					}
					else{
					$outputTarget=__DIR__ ."\docs\A4_bon_V".$A4TmplVersion."_".$bon_id."_".date('d_m_H_i').".pdf";
					$command="C:\sitpos\pdfxchange\App\PDFV_Portable\PDFXCview.exe /print:printer=\"$drucker\" \"$outputTarget\" ";
					$writeFile=$pdf->Output($outputTarget, "F");


					exec($command, $output, $error_code);
					if($writeFile == "" && $error_code == 0){
					if($testCall == 'testCall') echo json_encode(array("success", "printerPrint", $outputTarget ));
					else return array("success", "printerPrint", $outputTarget );

					}
					else{
					if($testCall == 'testCall') echo json_encode(array("$error_code", "printerPrint", $outputTarget ));
					else return array("$error_code", "printerPrint", $outputTarget );
					}



					}

					} # ende function a4pdf_DB($bon_id)