-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathex.php
More file actions
40 lines (31 loc) · 1.14 KB
/
ex.php
File metadata and controls
40 lines (31 loc) · 1.14 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
require dirname(dirname(__DIR__)) . '/fpdf/fpdf.php';
require __DIR__ . '/VariableStream.php';
require __DIR__ . '/PDFMemImageTrait.php';
use FPDF\Scripts\PDFMemImage\PDFMemImageTrait;
$pdf = new class extends FPDF {
use PDFMemImageTrait;
};
$pdf->AddPage();
// Load an image into a variable
$logo = file_get_contents(__DIR__ . '/logo.jpg');
// Output it
$pdf->MemImage($logo, 50, 30);
// Base64 Image
$pdf->MemImage(base64_encode($logo), 85, 30);
// Create a GD graphics
$im = imagecreate(200, 150);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
$bordercolor = imagecolorallocate($im, 0, 0, 0);
$color1 = imagecolorallocate($im, 255, 0, 0);
$color2 = imagecolorallocate($im, 0, 255, 0);
$color3 = imagecolorallocate($im, 0, 0, 255);
imagefilledrectangle($im, 0, 0, 199, 149, $bgcolor);
imagerectangle($im, 0, 0, 199, 149, $bordercolor);
imagefilledrectangle($im, 30, 100, 60, 148, $color1);
imagefilledrectangle($im, 80, 80, 110, 148, $color2);
imagefilledrectangle($im, 130, 40, 160, 148, $color3);
// Output it
$pdf->GDImage($im, 120, 25, 40);
$pdf->Output('F', __DIR__ . '/example.pdf');