Skip to content

Instantly share code, notes, and snippets.

@kbzone
Created September 6, 2021 15:40
Show Gist options
  • Save kbzone/bf2ce551f3434819fdcc65d35f47f0d0 to your computer and use it in GitHub Desktop.
Save kbzone/bf2ce551f3434819fdcc65d35f47f0d0 to your computer and use it in GitHub Desktop.
Generador de Factura AFIP en PDF
<?php
require_once(dirname(__FILE__) . '/library/TCPDF-main/tcpdf.php');
require_once(dirname(__FILE__) . '/library/FPDI-master/src/autoload.php');
use setasign\Fpdi;
class Pdf extends Fpdi\Tcpdf\Fpdi
{
protected $tplId;
private $source_file;
public function __construct($source_file)
{
parent::__construct();
$this->source_file = $source_file;
}
function Header()
{
if ($this->tplId === null) {
$this->setSourceFile($this->source_file);
$this->tplId = $this->importPage(1);
}
$size = $this->useImportedPage($this->tplId, ['adjustPageSize' => true]);
}
function Footer()
{
// emtpy method body
}
}
$pdf = new Pdf(PATH_TEMPLATE_PDF);
$pdf->setPageUnit('pt');
$pdf->SetMargins(-10, 40, 0);
$pdf->SetAutoPageBreak(true, 40);
$pdf->AddPage();
/* puedes llamar éstos dos métodos todas las veces que necesites */
$pdf->SetXY(COORDENADA_X, COORDENADA_Y);
$pdf->writeHTML('Texto que quieres incluir');
$pdf->Output(PATH_PDF_OUTPUT, 'F');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment