### Common DA Configuration Methods Source: https://context7.com/nfephp-org/sped-da/llms.txt This example shows common configuration methods available across all DA (Document Auxiliary) classes in the NFePHP library. These include settings for print parameters, logo, fonts, debug mode, footer customization, and rendering the document to a file or for browser output. ```php printParameters( $orientacao = 'P', // P=Portrait, L=Landscape $papel = 'A4', // A4, Letter, Legal, etc. $margSup = 2, // Top margin in mm $margEsq = 2 // Left margin in mm ); // Logo configuration $da->logoParameters( $logo = 'path/to/logo.png', // File path or data URI $logoAlign = 'C', // L=Left, C=Center, R=Right, F=Full $mode_bw = false // true for grayscale logo ); // Font settings $da->setDefaultFont('times'); // times, helvetica, courier, arial $da->setDefaultDecimalPlaces(2); // Number of decimal places for values // Debug and development $da->debugMode(true); // Shows construction lines and guides // Footer customization $da->creditsIntegratorFooter('Company Name - http://url.com'); // Disable default "Powered by NFePHP" footer $da->powered = false; // Set custom document title $da->setTitle('Custom Document Title'); // Render to string $pdfContent = $da->render($logo); // Save to file file_put_contents('output.pdf', $pdfContent); // Send to browser with proper headers header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="document.pdf"'); echo $pdfContent; // Force download header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="document.pdf"'); echo $pdfContent; ``` -------------------------------- ### Advanced DANFE Configuration Options Source: https://context7.com/nfephp-org/sped-da/llms.txt This snippet illustrates advanced configuration for the DANFE (Documento Auxiliar da Nota Fiscal EletrĂ´nica) class, allowing fine-grained control over displayed sections and visual elements. It covers tax information, product details, unit display, additional information fields, and visual customizations like dashed lines and contingency markings. ```php exibirPIS = true; // Show PIS/COFINS values $danfe->exibirIcmsInterestadual = true; // Show interstate ICMS details $danfe->exibirValorTributos = true; // Show approximate tax burden $danfe->exibirTextoFatura = true; // Show invoice/payment text // Product information display $danfe->descProdInfoComplemento = true; // Append tax info to product description $danfe->descProdInfoLoteTxt = true; // Include batch/lot information $danfe->exibirNumeroItemPedido = true; // Show purchase order item numbers // Unit display control $danfe->setOcultarUnidadeTributavel(false); // Show taxable unit when different from commercial $danfe->setQComCasasDec(4); // Decimal places for commercial quantity $danfe->setVUnComCasasDec(4); // Decimal places for commercial unit value // Additional information $danfe->exibirEmailDestinatario = true; // Show recipient email in additional info $danfe->setGerarInformacoesAutomaticas(true); // Auto-generate reference info $danfe->obsContShow(true); // Show observation field contributions // Visual customization $danfe->setUsarLinhaTracejadaSeparacaoItens(true); // Use dashed lines between items // Contingency marking $danfe->epec( $protocolo = '891180004131899', $data = '14/08/2018 11:24:45' ); // Custom title (appears in PDF metadata) $danfe->setTitle('DANFE - NF-e No. 123456'); $pdf = $danfe->render(); ``` -------------------------------- ### Generate BP-e PDF with DABPE Source: https://context7.com/nfephp-org/sped-da/llms.txt This snippet demonstrates how to generate a PDF for a BP-e (Bilhete de Passagem EletrĂ´nico) using the DABpe class. It requires an XML file containing the BP-e data and an optional logo file. The output is sent directly to the browser as a PDF. ```php debugMode(false); $dabpe->printParameters('P', 'A4', 2, 2); $dabpe->logoParameters($logo, 'L', false); $dabpe->creditsIntegratorFooter('Travel Agency - http://example.com'); $pdf = $dabpe->render(); header('Content-Type: application/pdf'); echo $pdf; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Generate Fiscal Event PDF from XML Source: https://context7.com/nfephp-org/sped-da/llms.txt Generates a PDF for fiscal document events such as cancellation, correction, or confirmation. Can handle single or multiple events and supports print parameters and logo configuration. Requires the 'NFePHP/DA/NFe/Daevento' class. ```php printParameters('P', 'A4'); // Optional: Add logo $logo = 'data://text/plain;base64,' . base64_encode(file_get_contents('logo.png')); $daevento->logoParameters($logo, 'L', false); // Generate single event PDF $pdf = $daevento->render(); // Alternative: Generate PDF with multiple events // $xmlArray = [$xml1, $xml2, $xml3]; // $pdf = $daevento->render(null, $xmlArray); header('Content-Type: application/pdf'); echo $pdf; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Generate DAMDFE PDF from XML Source: https://context7.com/nfephp-org/sped-da/llms.txt Generates a PDF representation of an Electronic Freight Manifest (MDF-e) from an XML file. Supports configuration of print parameters, logo, and footer credits. Requires the 'NFePHP/DA/MDFe/Damdfe' class and a valid MDF-e XML file. ```php debugMode(true); // Set integrator footer $damdfe->creditsIntegratorFooter('Fleet System - http://example.com'); // Set print orientation: 'P' for portrait (default), 'L' for landscape $damdfe->printParameters('P'); // Optional: Configure logo alignment // $damdfe->logoParameters($logo, 'L', false); // Generate PDF with logo $pdf = $damdfe->render($logo); // Output to browser header('Content-Type: application/pdf'); echo $pdf; } catch (Exception $e) { echo "Error processing DAMDFE: " . $e->getMessage(); } ``` -------------------------------- ### Generate DACTE OS PDF from XML Source: https://context7.com/nfephp-org/sped-da/llms.txt Generates a PDF representation of a Service Transport Document (CT-e OS) from an XML file. This is a specialized variant for service-oriented transport. Supports print parameters and logo configuration. Requires the 'NFePHP/DA/CTe/DacteOS' class. ```php debugMode(false); $dacteOS->printParameters('P', 'A4'); $dacteOS->logoParameters($logo, 'C', false); $dacteOS->creditsIntegratorFooter('Service Platform - http://example.com'); $pdf = $dacteOS->render(); header('Content-Type: application/pdf'); echo $pdf; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Generate DACTE PDF from XML Source: https://context7.com/nfephp-org/sped-da/llms.txt Generates a PDF representation of an Electronic Transport Document (CT-e) from an XML file. Supports configuration of print parameters, logo, and footer credits. Requires the 'NFePHP/DA/CTe/Dacte' class and a valid CT-e XML file. ```php debugMode(true); // Configure print parameters // Orientation: 'P' (portrait) or 'L' (landscape) // Paper: 'A4', 'Letter', etc. $dacte->printParameters('P', 'A4'); // Add integrator footer credits $dacte->creditsIntegratorFooter('Transport System - http://example.com'); // Set font family (times, helvetica, courier) $dacte->setDefaultFont('times'); // Configure logo display // Parameters: logo path, alignment (L/C/R), grayscale mode $dacte->logoParameters($logo, 'C', false); // Set decimal places for monetary values $dacte->setDefaultDecimalPlaces(2); // Optional: Add DPEC number for contingency // $dacte->depecNumber('12345678'); // Render the PDF $pdf = $dacte->render(); // Send to browser header('Content-Type: application/pdf'); echo $pdf; } catch (InvalidArgumentException $e) { echo "Error processing DACTE: " . $e->getMessage(); } ``` -------------------------------- ### Generate DANFE PDF from NF-e XML Source: https://context7.com/nfephp-org/sped-da/llms.txt This snippet demonstrates how to generate a DANFE (Electronic Invoice Auxiliary Document) PDF from an NF-e XML file using the NFePHPDANFeDanfe class. It includes configuration for display options, print parameters, logo, font, and decimal places. The generated PDF can be outputted directly or saved to a file. Dependencies include the 'vendor/autoload.php' file and a valid NF-e XML. ```php exibirTextoFatura = false; // Hide invoice text section $danfe->exibirPIS = false; // Hide PIS/COFINS values $danfe->exibirIcmsInterestadual = false; // Hide interstate ICMS $danfe->exibirValorTributos = false; // Hide approximate tax values $danfe->descProdInfoComplemento = false; // Don't append tax info to product description $danfe->exibirNumeroItemPedido = false; // Don't show purchase order item number $danfe->setOcultarUnidadeTributavel(true); // Hide taxable unit if same as commercial unit $danfe->obsContShow(false); // Hide observation field contributions // Set print parameters: orientation, paper size, top margin, left margin (in mm) $danfe->printParameters($orientacao = 'P', $papel = 'A4', $margSup = 2, $margEsq = 2); // Configure logo: image path/data, alignment (L/C/R/F), black&white mode $danfe->logoParameters($logo, $logoAlign = 'C', $mode_bw = false); // Set default font family $danfe->setDefaultFont($font = 'times'); // Set decimal places for unit values $danfe->setDefaultDecimalPlaces(4); // Enable/disable debug mode (shows construction lines) $danfe->debugMode(false); // Add integrator credits to footer $danfe->creditsIntegratorFooter('Company Name - http://example.com'); // Optional: Mark as authorized via EPEC (emergency contingency) // $danfe->epec('891180004131899', '14/08/2018 11:24:45'); // Generate PDF content $pdf = $danfe->render($logo); // Output PDF to browser header('Content-Type: application/pdf'); echo $pdf; // Alternative: Save to file // file_put_contents('danfe.pdf', $pdf); } catch (InvalidArgumentException $e) { echo "Error processing DANFE: " . $e->getMessage(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.