Created
September 6, 2021 15:40
-
-
Save kbzone/bf2ce551f3434819fdcc65d35f47f0d0 to your computer and use it in GitHub Desktop.
Generador de Factura AFIP en PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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