PHP code example of antradar / gspdf

1. Go to this page and download the library: Download antradar/gspdf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

antradar / gspdf example snippets




use GSPDF\GSPDF;

$pdf = new GSPDF();



use GSPDF\GSPDF;

use GSPDF\GSPDF;

$pdf = new GSPDF();
$pdf->addPage();
$pdf->SetFont('helvetica', '', 12);
$pdf->text(50, 50, 'Hello, World!');
$pdf->output('hello.pdf', 'F');

use GSPDF\GSPDF;
use GSPDF\HTML\HTMLModule;

$pdf = new GSPDF();
$htmlModule = new HTMLModule($pdf);
$pdf->loadHTMLModule($htmlModule);

$pdf->addPage();

$html = '<h1>Welcome to GSPDF</h1>
<p>This is <b>bold</b> and <i>italic</i> text.</p>
<ul>
    <li>Fast performance</li>
    <li>Low memory usage</li>
    <li>Easy to use</li>
</ul>';

$pdf->writeHTML($html);
$pdf->output('document.pdf', 'F');

// Download phpqrcode from: http://phpqrcode.sourceforge.net/

$pdf = new GSPDF([
    'qr_lib_path' => '/path/to/phpqrcode.php'
]);

$pdf->addPage();
$pdf->write2DBarcode(
    'https://github.com/your-repo/gspdf',
    'QRCODE,M',
    50, 50, 100, 100,
    ['border' => true, 'padding' => 2]
);
$pdf->output('qrcode.pdf', 'F');