-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf-api-test.php
executable file
·78 lines (54 loc) · 1.91 KB
/
pdf-api-test.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
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
<?
################################################################################
# copyright 2019 by Markus Olderdissen
# free for private use or inspiration.
# public use need written permission.
################################################################################
include_once("pdf-api.php");
_pdf_main();
#_pdf_test();
function _pdf_main()
{
$pdf["stream"] = file_get_contents("pdf-api-test.pdf");
$pdf["objects"] = _pdf_parse_document($pdf["stream"]);
# _pdf_filter_change($pdf);
_pdf_filter_change($pdf, "/FlateDecode");
# _pdf_filter_change($pdf, "/ASCIIHexDecode /FlateDecode");
$pdf["stream"] = _pdf_glue_document($pdf["objects"]);
$data = pdf_get_buffer($pdf);
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=parse-test.pdf");
header("Content-Length: " . strlen($data));
print($data);
}
function _pdf_test()
{
$pdf = pdf_new();
pdf_begin_document($pdf, "");
# returns /Fx where x is integer
$font = pdf_load_font($pdf, "Verdana", "winansi");
$font = pdf_load_font($pdf, "Courier", "winansi");
# returns /Fx where x is integer but returns error on unloaded font.
$font = pdf_findfont($pdf, "Verdana");
# returns /Xx where x is integer
$image = pdf_load_image($pdf, "png", "pdf-api-test.png");
foreach(range(1, 1) as $i)
{
pdf_begin_page($pdf, 595, 842);
# use return value of _pdf_add_font as fontname
pdf_setfont($pdf, $font, 72);
pdf_set_leading($pdf, 12);
pdf_show_xy($pdf, "ABC " . $i, 3, 3);
pdf_fit_image($pdf, $image, 20, 20, array("scale" => 10));
# store loaded resources
$page = pdf_end_page($pdf);
$outline = pdf_add_outline($pdf, "page " . $i, "", $page);
}
pdf_end_document($pdf);
$data = pdf_get_buffer($pdf);
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=parse-test.pdf");
header("Content-Length: " . strlen($data));
print($data);
}
?>