-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
84 lines (71 loc) · 2.8 KB
/
test.php
File metadata and controls
84 lines (71 loc) · 2.8 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
if (!class_exists('\Pdf\PdfText')) {
echo "PdfText doesn't exist\n";
return;
}
echo "Fonts: ".print_r(\Pdf\getFonts(),true)."\n";
/*
if (class_exists('\Pdf\PdfWriter')) {
echo "Writer exists\n";
$pdfWriter = new \Pdf\PdfWriter('./File.pdf', './Output.pdf');
echo "Set font...\n";
$pdfWriter->setFont("Arial");
echo "Font set\n";
echo "All Fonts: ".print_r($pdfWriter->getAllFonts(),true)."\n";
$pdfWriter->writeTextToPage(0, [
new \Pdf\PdfText(88.5,640,"The text to write\nTwo lines"),
new \Pdf\PdfText(88.5,540,"PLAN 7711449
BLOCK 8
LOT 39
EXCEPTING THEREOUT ALL MINES AND MINERALS"),
new \Pdf\PdfText(88.5,440,"Gnat defaced this PDF!")
]);
$pdfWriter->writeTextToPage(1, [
new \Pdf\PdfText(98.5,640,"The text to write"),
new \Pdf\PdfText(98.5,540,"More text to write"),
new \Pdf\PdfText(98.5,440,"Gnat defaced this PDF!")
]);
// $pdfWriter->writeTextToPage(0, [
// new \Pdf\PdfText(98.5, 640, "20 - The text to write - Archivo", 20, "Archivo"),
// new \Pdf\PdfText(98.5, 540, "9 - More text to write - Cormorant", 8,"Cormorant Garamond"),
// new \Pdf\PdfText(98.5, 440, "30-Gnat defaced this PDF! - Faustina", 30,"Faustina")
// ]);
echo "Wrote text\n";
$pdfWriter->save();
echo "Saved\n";
} else {
echo "Class doesn't exist\n";
}
*/
if (class_exists('\Pdf\PdfDocument')) {
//$pdfDocument = new \Pdf\PdfDocument('./File.pdf');
$pdfDoc = new \Pdf\PdfDocument('./test-output.pdf');
echo "Created On: ".$pdfDoc->getCreationDate()?->format('Y-m-d H:i:s')."\n";
echo "CreatedBy: ".$pdfDoc->getCreator()."\n";
echo "PDF Version: " . $pdfDoc->getMajorVersion() . '.' . $pdfDoc->getMinorVersion() . "\n";
echo "Is Encrypted: " . (($pdfDoc->isEncrypted() === true) ? 'Yes' : 'No') . "\n";
echo "Is Linear: " . (($pdfDoc->isLinear() === true) ? 'Yes' : 'No') . "\n";
echo "NumPages: " . $pdfDoc->getNumberOfPages() . "\n";
$txt = $pdfDoc->asString();
echo "TXT\n$txt\n\n";
echo "ORD: " . ord($txt) . "\n";
file_put_contents('./Output.txt', $pdfDoc->asString());
$path = getcwd()."/Output";
// $path = "/home/gnat/Projects/Web/prolegis/web/Output";
echo "Outputting as jpg...\n";
$res = $pdfDoc->toImage(\Pdf\PdfDocument::IMAGE_JPEG, $path, 300);
echo "Done...\n";
if ($res === false) {
echo "FAILED\n";
} else {
foreach($res as $pageNum => $pdfImageRest) {
echo "Page: $pageNum\n";
echo "\tImage: " . $pdfImageRest->getImageWidth() . " x " . $pdfImageRest->getImageHeight() . "\n";
echo "\tPage: " . $pdfImageRest->getPageWidth() . " x " . $pdfImageRest->getPageHeight() . "\n";
echo "\tPage: " . $pdfImageRest->getPage() . "\n";
}
}
echo ".. done\n";
} else {
echo "Class doesn't exist\n";
}