
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:24) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:24) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:24) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:26) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:26) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:26) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:26) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:28) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:28) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:28) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:28) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:30) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:30) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:30) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:30) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:32) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:32) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:32) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:32) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:34) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:34) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:34) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:34) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:36) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:36) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:36) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:36) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:38) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:38) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:38) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:38) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:40) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:40) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:40) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:40) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:42) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:42) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:42) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:42) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:44) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:44) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:44) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:44) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:46) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:46) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:46) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:46) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:48) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:48) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:48) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:48) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:50) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:50) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:50) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:50) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:52) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:52) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:52) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:52) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:54) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:54) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:54) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:54) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:56) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:56) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:56) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:56) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:57:58) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:57:58) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:57:58) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:57:58) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:58:00) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:58:00) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:58:00) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:58:00) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:58:02) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:58:02) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:58:02) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:58:02) - Error al guardar imagen localmente
[c2d2ce1d-36e0-4272-9357-8ecb215eff21](2025-07-18 06:58:04) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:58:04) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025-07-18 06:58:04) - Error al guardar imagen localmente
[3e413fd5-a509-4cfc-a85c-10770e6336d8](2025-07-18 06:58:04) - Error al guardar imagen localmente
[c9ee19b1-8d22-4287-8a4b-8b2871a025f8](2025-07-18 06:58:06) - Error al guardar imagen localmente
[52569634-b01c-4a94-8732-4a86bc217515](2025	// 	}
	// }
	
	// $params = $DOM->getElementsByTagName('Traslado');
	// foreach ($params as $param) {
	// 	if($param->getAttribute('Base') == "")
	// 	{
	// 		$TotImpuestos =  $TotImpuestos + $param->getAttribute('Importe');
		
	// 		if ($param->getAttribute('Impuesto')=="002")
	// 		{ // IVA
	// 			$ImporteTotalIVA = $ImporteTotalIVA + $param->getAttribute('Importe');    
	// 		}
			
	// 		if ($param->getAttribute('Impuesto')=="003")
	// 		{ // IEPS
	// 			$ImporteTotalIEPS = $ImporteTotalIEPS + $param->getAttribute('Importe');    
	// 		}
	// 	}
	// }
	
			
    if ($fechaTim != "")
	{
		$CadOri = "||".$versionTim."|".$UUID."|".$fechaTim."|".$rfcPAC."|".$selloCFD."|".$noCertificadoSAT."||";
	}
	else
	{
		$CadOri = "||".$versionTim."|".$UUID."|".$Fact_Fecha."|".$rfcPAC."|".$selloCFD."|".$noCertificadoSAT."||";
	}	
	
	#============================================================================================================
	#== 3. Crear archivo .PNG con codigo bidimensional 
	#============================================================================================================

	$filename = "";

	if ($UUID != "")
	{
		$filename 	= $SendaArchsGraf."/Img_".$UUID.".png";
		$CadImpTot 	= ProcesImpTot($total);
		$CadImpTot  = str_replace ( ",", '', $CadImpTot);
		$CadSello  	= substr($selloCFD,-8);
		$Cadena 	= "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?id=".$UUID."&re=".$Emisor_RFC."&rr=".$Receptor_RFC."&tt=".$CadImpTot."&fe=".$CadSello;
		QRcode::png($Cadena, $filename, 'H', 3, 2);    
		chmod($filename, 0777);  
	}

	#============================================================================================================
	#== 4. CONSTRUYENDO EL DOCUMENTOS CON LA LIBRERÍA FPDF 
	#============================================================================================================
	
	$pdf=new PDF('P','cm','Letter');
	$pdf->AliasNbPages();
	$pdf->AddPage();
	$pdf->AddFont('IDAutomationHC39M','','IDAutomationHC39M.php');
	$pdf->AddFont('verdana','','verdana.php');
	$pdf->SetAutoPageBreak(true);
	$pdf->SetMargins(0, 0, 0);
	$pdf->SetLineWidth(0.02);
	$pdf->SetFillColor(0,0,0);
	
	#============================================================================================================
	#== 4.1 ENCABEZADO DE LA FACTURA 
	#============================================================================================================
	
	$X = 0;
	$Y = 0;
	

	$pdf->image("archs_graf/Membrete_Fact_RZ.jpg",$X+1, $Y+1 , 9, 2.3);
	$pdf->image("archs_graf/LogoSAT.jpg",$X+16.6, $Y+3.4 , 0, 0);
	
	$pdf->SetTextColor(128,0,0);
	$pdf->SetFont('arial','B',13);
	$pdf->SetXY($X+11.7,$Y+1.20+0.1);
	$pdf->Cell(1.5, 0.25, "COMPROBANTE FISCAL DIGITAL", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+15.5,$Y+1.96);
	$pdf->Cell(2.5, 0.25, "FOLIO:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(171,17,17);
	$pdf->SetFont('arial','B',14);
	$pdf->SetXY($X+17,$Y+1.95);
	$pdf->Cell(1, 0.25, $Fact_NoFact, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+2.05);
	$pdf->Cell(2, 0.25, "FOLIO FISCAL:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+10.5+0.5,$Y+2.6);
	$pdf->Cell(2, 0.25, $UUID, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+2.5+0.6);
	$pdf->Cell(2, 0.25, "CERTIFICADO SAT:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+10.5+0.5,$Y+2.5+0.6+0.4);
	$pdf->Cell(2, 0.25, $noCertificadoSAT, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+4.06);
	$pdf->Cell(2, 0.25, "CERTIFICADO DEL EMISOR:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+10.5+0.5,$Y+4.06+0.4);
	$pdf->Cell(2, 0.25, $noCertificado, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+4.46+0.5);
	$pdf->Cell(2, 0.25, utf8_decode("FECHA HORA DE EMISIÓN:"), 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',9);
	$pdf->SetXY($X+10.5+0.5,$Y+4.46+0.5+0.34);
	$pdf->MultiCell(9.4, 0.35, str_replace("T"," ",utf8_decode($FechaHoraEmision)), 0, 'L');
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+6);
	$pdf->Cell(2, 0.25, utf8_decode("FECHA HORA DE CERTIFICACIÓN:"), 0, 1,'L', 0);
	
	$pdf->SetTextColor(17,71,121);
	$pdf->SetFont('arial','',9);
	$pdf->SetXY($X+10.5+5.5,$Y+6);
	$pdf->Cell(2, 0.25, str_replace("T"," ",$fechaTim), 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+10.5,$Y+6.6);
	$pdf->Cell(2, 0.25, utf8_decode("TIPO DE COMPROBANTE:"), 0, 1,'L', 0);
	
	$pdf->SetFont('arial','',9);
	$pdf->SetTextColor(17,71,121);
	$pdf->SetXY($X+14.7,$Y+6.6);
	$pdf->Cell(1, 0.25, utf8_decode("I - INGRESO"), 0, 1,'L', 0);

	$pdf->SetFont('arial','B',14);
	$pdf->SetTextColor(17,71,121);
	$pdf->SetXY($X+19.0,$Y+6.6);
	$pdf->Cell(1, 0.25, utf8_decode("v4.0"), 0, 1,'L', 0);
	$pdf->SetFont('arial','',9);

	$pdf->SetDrawColor(128,0,0);
	$pdf->SetLineWidth(0.05);
	$pdf->RoundedRect($X+10.4, $Y+1, 10, 6.14, 0.2, '');
	
	#============================================================================================================
	#== 4.2 DATOS DEL EMISOR
	#============================================================================================================
	
	#==$pdf->SetFillColor(84,141,212);
	$pdf->SetFillColor(223,234,247);
	$pdf->RoundedRect($X+1, $Y+3.5, 9, 3.64, 0.2, 'F');
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+1.05,$Y+3.7);
	$pdf->Cell(1, 0.25, "EMISOR:", 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',12);
	$pdf->SetXY($X+1.4,$Y+4.0+0.2);
	$pdf->MultiCell(8.6, 0.45, utf8_decode($Emisor_Nom), 0, 'C');
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05,$Y+3.7+0.45+1.25);
	$pdf->Cell(1, 0.25, "RFC:", 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+2.05,$Y+3.7+0.45+1.25);
	$pdf->Cell(1, 0.25, utf8_decode($Emisor_RFC), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+1.05,$Y+3.7+0.45+1.8);
	$pdf->Cell(1, 0.25, utf8_decode("LUGAR DE EXPEDICIÓN:"), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+1.05+4,$Y+3.7+0.45+1.8);
	$pdf->Cell(1, 0.25, $LugarExpedicion, 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',9);
	$pdf->SetXY($X+1.05,$Y+4.2+0.45+1.8);
	$pdf->Cell(1, 0.25, utf8_decode("RÉGIMEN FISCAL:"), 0, 1,'L', 0);
	
	#==$pdf->SetTextColor(255,255,255);
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',10);
	$pdf->SetXY($X+0.05+4,$Y+4.2+0.45+1.8);
	$pdf->Cell(1, 0.25, $Emisor_Regimen, 0, 1,'L', 0);
	$Y = $Y -1;
	
	#============================================================================================================
	#== 4.3 DATOS DEL RECEPTOR
	#============================================================================================================
	
	#==$pdf->SetFillColor(191,191,191);
	$pdf->SetFillColor(222,222,222);
	#==$pdf->SetFillColor(223,234,247);
	$pdf->RoundedRect($X+1, $Y+8.4, 19.4, 1.7, 0.2, 'F');
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',11);
	$pdf->SetXY($X+1.05,$Y+8.6);
	$pdf->Cell(1, 0.25, "RECEPTOR:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.5,$Y+8.4+0.60);
	$pdf->Cell(1, 0.25, utf8_decode($Receptor_Nom), 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, "RFC:", 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+1.05+0.9,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_RFC, 0, 1,'L', 0);
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+6,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("USO CFDI:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+6+2,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_UsoCFDI, 0, 1,'L', 0);

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+10,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("RÉGIMEN FISCAL:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+10+3.3,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_RegFis, 0, 1,'L', 0);

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+15.5,$Y+9.5+0.1);
	$pdf->Cell(2, 0.25, utf8_decode("CÓDIGO POSTAL:"), 0, 1,'L', 0);    
	
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+15.5+3.3,$Y+9.5+0.1);
	$pdf->Cell(1, 0.25, $Receptor_DomFis, 0, 1,'L', 0);   

	// DIRECCIÓN en la fila de abajo
	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','B',10);
	$pdf->SetXY($X+1.05, $Y+10.0); // <== se bajó la posición Y
	$pdf->Cell(2, 0.25, utf8_decode("DIRECCIÓN:"), 0, 1,'L', 0);   

	$pdf->SetTextColor(0,0,0);
	$pdf->SetFont('arial','',11);
	$pdf->SetXY($X+1.05+3.3, $Y+10.0);
	$pdf->Cell(1, 0.25, utf8_decode($Receptor_Direccion), 0, 1,'L', 0);

	$pdf->SetDrawColor(0,0,0);
	$pdf->SetLineWidth(0.02);    
	
	VerifStatusCFDI($pdf, $StatusCFDI);
	
	$Puntero	= 0;
	$a 			= 9.58;
	$b 			= 0;
	$c 			= 0;
	$Y 			= $Y + 1;
	
	#============================================================================================================
	#== 4.3 REGISTROS DE CFDI RELACIONADOS
	#============================================================================================================

	if($Tipo_Relacion <> "")
	{
		$Y = $pdf->GetY()+0.50;

		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','B',11);
		$pdf->SetXY($X+1.05,$Y);
		$pdf->Cell(1, 0.25, "CFDI RELACIONADOS", 0, 1,'L', 0);


		$pdf->SetFont('arial','',9);
		$pdf->SetXY($X+6.0,$Y);
		$pdf->Cell(1, 0.25, utf8_decode("Tipo de Relación: ").$Tipo_Relacion, 0, 1,'L', 0);

		$Y = $pdf->GetY()+0.20;

		$TotRegs = count($ArrayUUID);

		for ($i=0; $i<$TotRegs; $i++)
		{
			$YY = $pdf->GetY()+0.20;
			$Y = $YY;

			$pdf->SetFont('arial','',8);
			$pdf->SetTextColor(0,0,0);
			
			$pdf->SetXY($X+1.05,$Y);
			$pdf->Cell(1.5, 0.30, $ArrayUUID[$i], 0, 1,'L', 0);
		}
	}
	
	#============================================================================================================ 
	#== 4.3 REGISTROS DE ARTÍCULOS 
	#============================================================================================================
	
	$Y = $pdf->GetY()+0.20;
	
	if (strlen($Obs)==0)
	{
		$Y = $Y + 1.1;
	}
	else
	{
		$Y = $Y + 0.8;
	}
	
	$Regs 			= 0;
	$RefAgregPag 	= 0;
	
	Titulos($pdf, $Y-0.8);    
	
	$TotRegs = count($ArrayCant);
	
	for ($i=0; $i<$TotRegs; $i++)
	{
		$pdf->SetFont('arial','',8);
		$pdf->SetTextColor(0,0,0);
		
		$pdf->SetXY($X+0.75,$Y);
		$pdf->Cell(1.5, 0.30, $ArrayCant[$i], 0, 1,'C', 0);
		
		$pdf->SetXY($X+1.975,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode($ArrayClaArtSer[$i]), 0, 1,'L', 0);
		
		$pdf->SetXY($X+2.6,$Y);
		$pdf->MultiCell(2.0, 0.30, utf8_decode($ArrayUniMed[$i]), 0, 'L', 0);
		
		$pdf->SetXY($X+4.5,$Y);
		$pdf->Cell(2.0, 0.30, utf8_decode($ArrayCvePro[$i]), 0, 1,'L', 0);

		$pdf->SetXY($X+6.2,$Y);
		$pdf->Cell(1.7, 0.30, number_format($ArrayPreUni[$i],2), 0, 1,'R', 0);
		
		$pdf->SetXY($X+8.0,$Y);
		$pdf->Cell(1.8, 0.30, number_format($ArrayImporte[$i],2), 0, 1,'R', 0);

		$pdf->SetXY($X+10.6,$Y);
		$pdf->Cell(1.8, 0.30, number_format($ArrayDescuento[$i],2), 0, 1,'R', 0);

		$pdf->SetXY($X+12.8,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode($ArrayObjImpu[$i]), 0, 1,'C', 0); 

		if($lTipImp == 1)
		{
			$pdf->SetXY($X+13.75,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoBase[$i],2), 0, 1,'R', 0);

			$pdf->SetXY($X+15.6,$Y);
			$pdf->Cell(1.0, 0.30, $ArrayTrasladoImpu[$i], 0, 1,'L', 0);

			$pdf->SetXY($X+16.4,$Y);
			$pdf->Cell(1.0, 0.30, $ArrayTrasladoTipo[$i], 0, 1,'L', 0);

			$pdf->SetXY($X+16.8,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoTasa[$i],6), 0, 1,'R', 0);

			$pdf->SetXY($X+18.5,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayTrasladoImpo[$i],2), 0, 1,'R', 0);
		}

		if($lTipImp == 2)
		{
			$pdf->SetXY($X+13.75,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayRetencionBase[$i],2), 0, 1,'R', 0);

			$pdf->SetXY($X+15.6,$Y);
			$pdf->Cell(1.0, 0.30, $ArrayRetencionImpu[$i], 0, 1,'L', 0);

			$pdf->SetXY($X+16.4,$Y);
			$pdf->Cell(1.0, 0.30, $ArrayRetencionTipo[$i], 0, 1,'L', 0);

			$pdf->SetXY($X+16.8,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayRetencionTasa[$i],6), 0, 1,'R', 0);

			$pdf->SetXY($X+18.5,$Y);
			$pdf->Cell(1.8, 0.30, number_format($ArrayRetencionImpo[$i],2), 0, 1,'R', 0);
		}
		

		$pdf->line($X+1, $Y-0.1, $X+20.4, $Y-0.1);

		$Y = $Y + 0.35;
		$pdf->SetFont('arial','B',8);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetXY($X+1.0,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode("Descripción:"), 0, 1,'L', 0);

		$pdf->SetFont('arial','',8);
		$pdf->SetTextColor(0,0,0);
		$pdf->SetXY($X+2.8,$Y);
		$pdf->MultiCell(17.3, 0.30, utf8_decode($ArrayArtSer[$i]), 0, 'J', 0);
		//$pdf->Write(0.4,'');

		$YY 		= $pdf->GetY()+0.18;
		$Puntero 	= $pdf->GetY();
		
		$Y = $YY;
		$Regs++;
	
		if ($Puntero>23.5)
		{
			if ($TotRegs>$Regs)
			{
				$pdf->AddPage();
				Titulos($pdf, 1.5);
				$Y = 2.4;
			}
			else
			{
				$pdf->AddPage();
				$Y = 1.4;
			}
		}  
	}    
	
	
	#============================================================================================================
	#== 4.4 IMPRESIÓN DE LOS SUBTOTALES.
	#============================================================================================================
	if ($Puntero<=23.5)
	{
		$Y = 18.00; 
		SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR);
	}
	
	if ($Puntero>23.5 && $TotRegs==$Regs)
	{
		SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR);
	}
	
	
	#============================================================================================================
	#== 4.5 IMPRESIÓN DE LOS DATOS INFERIORES.
	#============================================================================================================
	if ($Puntero<18.5)
	{
		if ($filename != "")
		{
			DatosInf($pdf, $filename, 0, $selloCFD, $selloSAT, $CadOri, $PaginaWeb);
		}
	}
	
	if ($Puntero>=18.5 && $Puntero<23.5)
	{
		$pdf->AddPage();
		//$pdf->image("archs_graf/FondoTenue.jpg",1, 5 , 19.5, 18);        
		if ($filename != "")
		{
			DatosInf($pdf, $filename, -20.5, $selloCFD, $selloSAT, $CadOri, $PaginaWeb);
		}
	}    
	
	if ($Puntero>=23.5)
	{
		if ($filename != "")
		{
			DatosInf($pdf, $filename, $Puntero -41, $selloCFD, $selloSAT, $CadOri, $PaginaWeb);
		}
	}    

	
	#============================================================================================================
	#== 4.6 SE GRABA EL DOCUMENTO .PDF EN EL DISCO DURO
	#============================================================================================================
	
	$pdf->Output($SendaArchsCFDI.$NomArchPDF, 'F'); 
	
	#============================================================================================================
	#== 4.7 DESCOMENTAR SI ESTÁ UTILIZANDO EL SISTEMA OPERATIVO LINUX.
	#============================================================================================================

	chmod ($SendaArchsCFDI.$NomArchPDF,0777);  
	
	#============================================================================================================
	#== 4.8 SE MUESTRA EL DOCUMENTO .PDF EN EL NAVEGADOR.
	#============================================================================================================

	$pdf->Output($SendaArchsCFDI.$NomArchPDF, 'I');

	
	#============================================================================================================
	#== FUNCIONES GENERALES
	#============================================================================================================
	function Titulos($pdf, $Y){
		$Y = $Y + 0.24;
		
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','B',8);    
		
		$pdf->SetXY(0.75,$Y);
		$pdf->Cell(1.5, 0.30, "Cant.", 0, 1,'C', 0);
		
		$pdf->SetXY(1.95,$Y);
		$pdf->Cell(1.8, 0.30, "Unidad", 0, 1,'L', 0);
		
		$pdf->SetXY(4.5,$Y);
		$pdf->Cell(3.3, 0.30, "Clave", 0, 1,'L', 0);
		
		$pdf->SetXY(6.2,$Y);
		$pdf->Cell(1.7, 0.30, utf8_decode("V. Unitario"), 0, 1,'R', 0);
		
		$pdf->SetXY(8.0,$Y);
		$pdf->Cell(1.8, 0.30, utf8_decode("Importe"), 0, 1,'R', 0);    

		$pdf->SetXY(10.6,$Y);
		$pdf->Cell(1.8, 0.30, utf8_decode("Descuento"), 0, 1,'R', 0);    

		$pdf->SetXY(12.8,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode("Objeto"), 0, 1,'L', 0);

		$pdf->SetXY(13.75,$Y);
		$pdf->Cell(1.7, 0.30, utf8_decode("Base"), 0, 1,'R', 0);

		$pdf->SetXY(15.5,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode("Impto"), 0, 1,'L', 0);

		$pdf->SetXY(16.4,$Y);
		$pdf->Cell(1.0, 0.30, utf8_decode("Tipo"), 0, 1,'L', 0);

		$pdf->SetXY(16.8,$Y);
		$pdf->Cell(1.7, 0.30, utf8_decode("Tasa"), 0, 1,'R', 0);

		$pdf->SetXY(18.5,$Y);
		$pdf->Cell(1.8, 0.30, utf8_decode("Importe"), 0, 1,'R', 0);    
	}
	
	function SubTotales($pdf, $Y, $subTotal, $descuento, $ImporteTotalIVA, $ImporteTotalIEPS, $total, $formaDePago, $metodoDePago, $NumCtaPago, $Puntero, $moneda, $tipoCambio, $ImporteTotalISR, $ImporteTotalIVAR){
		$X = 0;
		$Y = $Y - 0.00;
		
		//== Subtotales ============================================================
		
		$pdf->SetTextColor(0,0,0);
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+16.27,$Y+0.35);
		$pdf->Cell(1.7, 0.30, "Subtotal:", 0, 1,'R', 0);    
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+16.16+2.5,$Y+0.35);
		$pdf->Cell(1.7, 0.30, number_format($subTotal,2), 0, 1,'R', 0);    
		
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+16.27,$Y+0.35+0.5);
		$pdf->Cell(1.7, 0.30, "Descuento:", 0, 0,'R', 0);    
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+16.16+2.5,$Y+0.35+0.5);
		$pdf->Cell(1.7, 0.30, number_format($descuento,2), 0, 1,'R', 0);
	
		if ($ImporteTotalIVAR > 0)
		{
			$pdf->SetFont('arial','B',9);         
			$pdf->SetXY($X+16.27,$Y+0.35+(0.5*2));
			$pdf->Cell(1.7, 0.30, "IVA RETENIDO:", 0, 0,'R', 0);
			
			$pdf->SetFont('arial','',9);
			$pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*2));
			$pdf->Cell(1.7, 0.30, number_format($ImporteTotalIVAR,2), 0, 1,'R', 0);
		}

		if ($ImporteTotalISR > 0)
		{
			$pdf->SetFont('arial','B',9);         
			$pdf->SetXY($X+16.27,$Y+0.35+(0.5*2));
			$pdf->Cell(1.7, 0.30, "IMPUESTOS RETENIDOS:", 0, 0,'R', 0);
			
			$pdf->SetFont('arial','',9);
			$pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*2));
			$pdf->Cell(1.7, 0.30, number_format($ImporteTotalISR,2), 0, 1,'R', 0);
		}
		
		//== $pdf->SetFont('arial','B',9);         
		//== $pdf->SetXY($X+16.27,$Y+0.35+(0.5*2));
		//== $pdf->Cell(1.7, 0.30, "IMPUESTOS RETENIDOS:", 0, 0,'R', 0);

		$pdf->SetFont('arial','B',9);         
		$pdf->SetXY($X+16.27,$Y+0.35+(0.5*3));
		$pdf->Cell(1.7, 0.30, "IVA:", 0, 0,'R', 0);
		
		$pdf->SetFont('arial','',9);
		$pdf->SetXY($X+16.16+2.5,$Y+0.35+(0.5*3));
		$pdf->Cell(1.7, 0.30, number_format($ImporteTotalIVA,2), 0, 1,'R', 0);
		
		$pdf->SetFont('arial','B',9);
		$pdf->SetXY($X+16.27,$Y+0.37+(0.5*4));
		$pdf->Cell(1.7, 0.30, "Total:", 0, 1,'R', 0);    
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+16.16+2.5,$Y+0.37+(0.5*4));
		$pdf->Cell(1.7, 0.30, number_format($total,2), 0, 1,'R', 0);    
		
		//================================================================
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+1,$Y+0.35);
		$pdf->Cell(1.7, 0.30, "Total con letra: ", 0, 1,'L', 0);    
		
		$pdf->SetFont('arial','',8); 
		$pdf->SetXY($X+1,$Y+0.35+0.40);
		//$pdf->Cell(1.7, 0.30, NumLet($total,$moneda), 0, 1,'L', 0);
		$pdf->Cell(1.7, 0.30, convertirNumeroLetra($total,$moneda), 0, 1,'L', 0);
		
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+1,$Y+0.35+0.40+0.8);
		$pdf->Cell(1.7, 0.30, "Forma de pago:", 0, 1,'L', 0);
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+3.6,$Y+0.35+0.40+0.8);
		$pdf->Cell(1.7, 0.30, utf8_decode($formaDePago), 0, 1,'L', 0);   
		
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+9.15,$Y+0.35+0.40+0.8);
		$pdf->Cell(1.7, 0.30, "Moneda:", 0, 1,'L', 0);
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+10.7,$Y+0.35+0.40+0.8);
		$pdf->Cell(1.7, 0.30, utf8_decode($moneda), 0, 1,'L', 0);   
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+1,$Y+0.35+0.40+1.3);
		$pdf->Cell(1.7, 0.30, utf8_decode("Método de pago:"), 0, 1,'L', 0);
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+3.76,$Y+0.35+0.40+1.3);
		$pdf->Cell(1.7, 0.30, utf8_decode($metodoDePago), 0, 1,'L', 0);   
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY($X+8,$Y+0.35+0.40+1.3);
		$pdf->Cell(1.7, 0.30, utf8_decode("Tipo de Cambio:"), 0, 1,'L', 0);
		
		$pdf->SetFont('arial','',9); 
		$pdf->SetXY($X+10.7,$Y+0.35+0.40+1.3);
		$pdf->Cell(1.7, 0.30, number_format($tipoCambio,4), 0, 1,'L', 0);   
		
		$pdf->SetDrawColor(128,0,0);
		$pdf->SetLineWidth(0.05);
		$pdf->RoundedRect($X+1, $Y+0.15, 19.4, 2.60, 0.2, '');
		$pdf->SetDrawColor(0,0,0);
		$pdf->SetLineWidth(0.02);    
		
		
		if (strlen($NumCtaPago)>0){
			$pdf->SetFont('arial','B',9); 
			$pdf->SetXY($X+1,$Y+0.35+0.40+1.8);
			$pdf->Cell(1.7, 0.30, utf8_decode("Número de cuenta:"), 0, 1,'L', 0);
			
			$pdf->SetFont('arial','',9); 
			$pdf->SetXY($X+3.76+0.3,$Y+0.35+0.40+1.8);
			$pdf->Cell(1.7, 0.30, $NumCtaPago, 0, 1,'L', 0);   
		}
	}
	
	
	function DatosInf($pdf, $filename, $Y, $selloCFD, $selloSAT, $CadOri, $PaginaWeb){
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY(1.2,22.9+$Y-0.2 -0.7);
		$pdf->Cell(1.7,0.30, "Sello digital del CFDI:", 0, 1,'L', 0);    
		
		$pdf->SetFont('arial','',7); 
		$pdf->SetXY(1.2,+22.9+0.35+$Y-0.2 -0.7);
		$pdf->MultiCell(19.4, 0.25, $selloCFD, 0, 'L', 0);
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY(4.2,21.9+2+$Y -0.7);
		$pdf->Cell(1.7, 0.30, "Sello del SAT:", 0, 1,'L', 0);    
		
		$pdf->SetFont('arial','',7); 
		$pdf->SetXY(4.2,21.9+0.35+2+$Y -0.7);
		$pdf->MultiCell(16.1, 0.25, $selloSAT, 0, 'L', 0);
		
		$pdf->SetFont('arial','B',9); 
		$pdf->SetXY(4.2,25+0.5+$Y -0.7);
		$pdf->Cell(1.7, 0.30, utf8_decode("Cadena original del complemento de certificación digital del SAT:"), 0, 1,'L', 0);    
		
		$pdf->SetFont('arial','',7); 
		$pdf->SetXY(4.2,25.1+0.5+0.25+$Y -0.7);
		$pdf->MultiCell(16.1, 0.25, $CadOri, 0, 'L', 0);
		
		if ($filename != "")
		{
			$pdf->Image($filename,1.2,23.8+$Y -0.7,3,3,'PNG');
		}
	}
	
	
	function ProcesImpTot($ImpTot){
		$ImpTot 		= number_format($ImpTot, 4); 
		$ArrayImpTot 	= explode(".", $ImpTot);
		$NumEnt 		= $ArrayImpTot[0];
		$NumDec 		= ProcesDecFac($ArrayImpTot[1]);
		return $NumEnt.".".$NumDec;
	}
	
	
	function ProcesDecFac($Num){
		$FolDec = "";
		if ($Num < 10){$FolDec = "00000".$Num;}
		if ($Num > 9 and $Num < 100){$FolDec = $Num."0000";}
		if ($Num > 99 and $Num < 1000){$FolDec = $Num."000";}
		if ($Num > 999 and $Num < 10000){$FolDec = $Num."00";}
		if ($Num > 9999 and $Num < 100000){$FolDec = $Num."0";}
		return $FolDec;	
	}    
	
	
	function VerifStatusCFDI($pdf, $StatusCFDI){
		if ($StatusCFDI=="CANCELADO"){
			$pdf->SetLineWidth(0.1);
			$pdf->SetDrawColor(200,0,0);        
			$pdf->SetTextColor(200,0,0);
			$pdf->SetFont('verdana','',53); 
			
			$pdf->RoundedRect(4.4, 7.4-2.5, 12.6, 2.05, 0.4, '');
			$pdf->SetXY(1,8.4-2.5);
			$pdf->Cell(19.4, 0.30, "CANCELADO", 0, 1,'C', 0);    
			
			$pdf->SetLineWidth(0.02);
			$pdf->SetDrawColor(0,0,0);        
			$pdf->SetTextColor(0,0,0);
		}
	}       
	
	
		