PHP code example of yetiforce / yetiforcepdf

1. Go to this page and download the library: Download yetiforce/yetiforcepdf 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/ */

    

yetiforce / yetiforcepdf example snippets



$loader = w YetiForcePDF\Document())->init();
$document->loadHtml('<div style="text-align:center;">your html goes here</div>');
$pdfFile = $document->render();
file_put_contents('YourPDF.pdf', $pdfFile);

<div data-font data-family="Your Font Name" data-weight="400" data-style="normal" data-file="/absolute/path/to/font/file/YourFontName-Regular.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="400" data-style="italic" data-file="/absolute/path/to/font/file/YourFontName-Italic.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="800" data-style="normal" data-file="/absolute/path/to/font/file/YourFontName-Bold.ttf"></div>
<div data-font data-family="Your Font Name" data-weight="800" data-style="italic" data-file="/absolute/path/to/font/file/YourFontName-BoldItalic.ttf"></div>

\YetiForcePDF\Document::addFonts([
	[
		'family' => 'Pacifico',
		'weight' => '400',
		'style' => 'normal',
		'file' => '/absolute/path/to/Pacifico/Pacifico-Regular.ttf'
	],
	[
		'family' => 'Lobster Two',
		'weight' => '400',
		'style' => 'normal',
		'file' => '/absolute/path/to/Lobster_Two/LobsterTwo-Regular.ttf'
	],
	[
		'family' => 'Lobster Two',
		'weight' => 'bold',
		'style' => 'normal',
		'file' => '/absolute/path/to/Lobster_Two/LobsterTwo-Bold.ttf'
	],
]);

<div data-header>
    <table style="border:1px solid greenyellow;font-size:12px;margin:10px;background-color:yellow;width:100%">
        <tr>
            <td style="width:50%;border:1px solid red;">This is a page header</td>
            <td style="text-align:right;border:1px solid red;">which could be table</td>
        </tr>
    </table>
</div>
<div data-footer>
    <div style="border:1px solid greenyellow;font-size:14px;margin:10px;">
        <div style="text-align:center">Footer</div>
    </div>
</div>
<div data-watermark style="text-align:center;">
    <div style="display:inline-block;font-size:20px;opacity:0.25;">
        <img src="Image.jpg">
    </div>
</div>

<div data-page-group
     data-format="A4"
     data-orientation="P"
     data-margin-left="30"
     data-margin-right="30"
     data-margin-top="40"
     data-margin-bottom="40"
     data-header-top="10"
     data-footer-bottom="10"
></div>

<div style="page-break-after:always;"></div>

<div data-footer>
    <div style="border:1px solid greenyellow;font-size:14px;margin:10px;">
        <div style="text-align:center">Page {p} / {a}</div>
    </div>
</div>

<div data-barcode="EAN13" data-size="1" data-height="16" data-code="9780691147727"></div>