-
Notifications
You must be signed in to change notification settings - Fork 84
/
test.php
70 lines (60 loc) · 2.47 KB
/
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
<?php
use com\grandt\EPub;
include_once("EPub.php");
error_reporting(E_ALL | E_STRICT);
ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 1);
// Example.
// Create a test book for download.
// ePub uses XHTML 1.1, preferably strict.
$content_start =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
. "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n"
. " \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
. "<head>"
. "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
. "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\" />\n"
. "<title>Test Book</title>\n"
. "</head>\n"
. "<body>\n";
$content_end = "</body>\n</html>\n";
$blogurl = "http://test.com/";
$cssData = "body {\n margin-left: .5em;\n margin-right: .5em;\n text-align: justify;\n}\n\np {\n font-family: serif;\n font-size: 10pt;\n text-align: justify;\n text-indent: 1em;\n margin-top: 0px;\n margin-bottom: 1ex;\n}\n\nh1, h2 {\n font-family: sans-serif;\n font-style: italic;\n text-align: center;\n background-color: #6b879c;\n color: white;\n width: 100%;\n}\n\nh1 {\n margin-bottom: 2px;\n}\n\nh2 {\n margin-top: -2px;\n margin-bottom: 2px;\n}\n";
$book = new EPub();
$book->setTitle("test");
$authorname = "Ima Author";
$book->setAuthor($authorname, $authorname);
$book->setIdentifier($blogurl . "&stamp=" . time(), EPub::IDENTIFIER_URI);
$book->setLanguage("en");
$book->addCSSFile("styles.css", "css1", $cssData);
$cover = $content_start . "<h1>" . "test" . "</h1>\n";
if ($authorname) {
$cover .= "<h2>By: $authorname</h2>\n";
}
$cover .= "<h2>From: <a href=\"$blogurl\">$blogurl</a></h2>";
$cover .= $content_end;
$book->addChapter("Notices", "Cover.html", $cover);
$book->buildTOC();
$book->addChapter(
"Chapter 1",
"Chapter1.html",
$content_start . "<h1>Chapter 1</h1>\n<p>Plenty of test content</p>\n" . $content_end
);
$book->addChapter(
"Chapter 2",
"Chapter2.html",
$content_start . "<h1>Chapter 2</h1>\n<p>Plenty of test content</p>\n" . $content_end
);
$book->addChapter(
"Chapter 3",
"Chapter3.html",
$content_start . "<h1>Chapter 3</h1>\n<p>Plenty of test content</p>\n" . $content_end
);
$book->addChapter(
"Epilogue",
"Epilogue.html",
$content_start . "<h1>Epilogue</h1>\n<p>Plenty of test content</p>\n" . $content_end
);
$book->finalize();
$zipData = $book->sendBook("ExampleBook1_test");