PHP code example of from-home-de / pdf-label

1. Go to this page and download the library: Download from-home-de/pdf-label 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/ */

    

from-home-de / pdf-label example snippets


 declare(strict_types=1);

use FromHome\Pdf\Label;

$pdf = Label::newFromLabelType(Label::TYPE_L7161);

for($i= 0; $i < $pdf->getLabelsCount(); $i++)
{
    $pdf->addLabel('Label text ' . $i);
}

$pdf->save('/path/to/Labels.pdf');

 declare(strict_types=1);

use FromHome\Pdf\Label;

$formatDefinition = [
    'paper-size' => 'A4',
    'unit'       => Label::UNIT_MILLIMETER,
    'marginLeft' => 7,
    'marginTop'  => 10.5,
    'NX'         => 2,
    'NY'         => 2,
    'SpaceX'     => 0,
    'SpaceY'     => 0,
    'width'      => 98,
    'height'     => 138,
    'cutLines'   => true,
];

$pdf = Label::newFromFormatDefinition($formatDefinition);

for($i= 0; $i < $pdf->getLabelsCount(); $i++)
{
    $pdf->addLabel('Label text ' . $i);
}
$pdf->save('/path/to/Labels.pdf');

$pdf->save('/path/to/Labels.pdf');

$pdf->serveInline('Labels.pdf');

$pdf->serveAsDownload('Labels.pdf');

$content = $pdf->getContent();



use FromHome\Pdf\Label;

final class MyLabel extends Label
{
    public function setUpDocument() : void
    {
        # setup stuff like default font and font-size here         
    }

    public function Header() : void
    {
        # Create a custom header here
        # See: https://tcpdf.org/examples/example_003/
    }
    public function Footer() : void
    {
        # Create a custom footer here
        # See: https://tcpdf.org/examples/example_003/
    }
}