-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
72 lines (55 loc) · 2.41 KB
/
index.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
<?php
// This is only to make sure the charset is UTF-8
// You may remove this line.
header('Content-Type: text/html; charset=utf-8');
// The class is in the folder classes
require 'classes/TPEpubCreator.php';
// Here we go
$epub = new TPEpubCreator();
// Temp folder and epub file name (path)
$epub->temp_folder = 'temp_folder/';
$epub->epub_file = 'epubs/epub_name.epub';
// E-book configs
$epub->title = 'Epub title';
$epub->creator = 'Luiz Otávio Miranda';
$epub->language = 'pt';
$epub->rights = 'Public Domain';
$epub->publisher = 'http://www.tutsup.com/';
// You can specity your own CSS
$epub->css = file_get_contents('base.css');
// $epub->uuid = ''; // You can specify your own uuid
// Add page from file (just the <body> content)
// You have to remove doctype, head and body tags
// Sintax: $epub->AddPage( XHTML, file, title, download images );
$epub->AddPage( false, 'file.txt', 'Título (check accent)' );
// Add page content directly (just the <body> content)
// You must not use doctype, head and body tags (only XHTML body content)
$epub->AddPage( '<b>Test</b>', false, 'Title 2' );
$epub->AddPage( '<img src="images/2.jpg" />', false, 'Title 3' );
// Here the last param tells the class to download de image
$epub->AddPage( '<img src="images/3.jpg" />', false, 'Title 4', true );
$epub->AddPage( '<img src="images/4.jpg" />', false, 'Title 5' );
// Add image cover
// Make sure only one image is set to cover (last argument = true).
// If more than one image is set to cover, readers would not load the e-book.
// Sintax: $epub->AddImage( image path, mimetype, cover );
$epub->AddImage( 'images/1.jpg', false, true );
// Add another images (last arg is set to false - not cover - remember that)
$epub->AddImage( 'images/2.jpg', 'image/jpeg', false );
// If you don't send the mimetype, the class will try to get it from the file
$epub->AddImage( 'images/4.jpg', false, false );
// Create the EPUB
// If there is some error, the epub file will not be created
if ( ! $epub->error ) {
// Since this can generate new errors when creating a folder
// We'll check again
$epub->CreateEPUB();
// If there's no error here, you're e-book is successfully created
if ( ! $epub->error ) {
echo 'Success: Download your book <a href="' . $epub->epub_file . '">here</a>.';
}
} else {
// If for some reason you're e-book hasn't been created, you can see whats
// going on
echo $epub->error;
}