-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateArPdf.php
28 lines (21 loc) · 1.01 KB
/
generateArPdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Omaralalwi\Gpdf\Gpdf;
use Omaralalwi\Gpdf\GpdfConfig;
use Omaralalwi\Gpdf\Enums\{GpdfDefaultSettings, GpdfSettingKeys as confKeys, GpdfDefaultSupportedFonts};
$html = file_get_contents(__DIR__ . '/contents/example-3-arabic-content.html');
// pass config file
$gpdfConfigFile = require_once 'config/gpdf.php';
$config = new GpdfConfig($gpdfConfigFile);
// another way by pass configs instantly (inline)
// NOTE: When pass config inline, you must provide Font dir and font cache config keys, to get their real path depend on current file path
//$config = new GpdfConfig([
// confKeys::FONT_DIR => realpath(__DIR__.'/public/vendor/gpdf/fonts/'),
// confKeys::FONT_CACHE => realpath(__DIR__.'/public/vendor/gpdf/fonts/'),
// confKeys::DEFAULT_FONT => GpdfDefaultSupportedFonts::TAJAWAL,
// confKeys::IS_JAVASCRIPT_ENABLED => true,
//]);
$gpdf = new Gpdf($config);
$pdfContent = $gpdf->generate($html);
header('Content-Type: application/pdf');
echo $pdfContent;