1EBook::EPUB(3) User Contributed Perl Documentation EBook::EPUB(3)
2
3
4
6 EBook::EPUB - module for generating EPUB documents
7
9 Version 0.5
10
12 use EBook::EPUB;
13
14 # Create EPUB object
15 my $epub = EBook::EPUB->new;
16
17 # Set metadata: title/author/language/id
18 $epub->add_title('Three Men in a Boat');
19 $epub->add_author('Jerome K. Jerome');
20 $epub->add_language('en');
21 $epub->add_identifier('1440465908', 'ISBN');
22
23 # Add package content: stylesheet, font, xhtml and cover
24 $epub->copy_stylesheet('/path/to/style.css', 'style.css');
25 $epub->copy_file('/path/to/figure1.png',
26 'figure1.png', 'image/png');
27 $epub->encrypt_file('/path/to/CharisSILB.ttf',
28 'CharisSILB.ttf', 'application/x-font-ttf');
29 my $chapter_id = $epub->copy_xhtml('/path/to/page1.xhtml',
30 'page1.xhtml');
31 $epub->copy_xhtml('/path/to/notes.xhtml', 'notes.xhtml',
32 linear => 'no'
33 );
34
35 # Add top-level nav-point
36 my $navpoint = $epub->add_navpoint(
37 label => "Chapter 1",
38 id => $chapter_id,
39 content => 'page1.xhtml',
40 play_order => 1 # should always start with 1
41 );
42
43 # Add cover image
44 # Not actual epub standart but does the trick for iBooks
45 my $cover_id = $epub->copy_image('/path/to/cover.jpg', 'cover.jpg');
46 $epub->add_meta_item('cover', $cover_id);
47
48 # Generate resulting ebook
49 $epub->pack_zip('/path/to/three_men_in_a_boat.epub');
50
52 new([$params])
53 Create an EBook::EPUB object
54
55 add_title($title)
56 Set the title of the book
57
58 add_identifier($id, [$scheme])
59 Set a unique identifier for the book, such as its ISBN or a URL
60
61 add_author($name, [$formal_name])
62 Add author of the document. For details see add_contributor.
63
64 add_creator($name, [fileas => $formal_name, role => $role])
65 Add primary creator or author of the publication of the
66 publication. See add_contributor for details
67
68 add_contributor($name, [fileas => $formal_name, role =>])
69 Add person/organization that contributed to publication. $name is
70 the name in human-readable form, e.g. "Arthur Conan Doyle",
71 $formal_name is in form, suitable for machine processing, e.g.
72 "Doyle, Arthur Conan". $role reflects kind of contribution to
73 document. See Section 2.2.6 of OPF specification for list of
74 possible values
75 <http://www.idpf.org/2007/opf/OPF_2.0_final_spec.html#Section2.2.6>
76
77 add_date($date, [$event])
78 Date of publication, in the format defined by "Date and Time
79 Formats" at http://www.w3.org/TR/NOTE-datetime and by ISO 8601 on
80 which it is based. In particular, dates without times are
81 represented in the form YYYY[-MM[-DD]]: a required 4-digit year, an
82 optional 2-digit month, and if the month is given, an optional
83 2-digit day of month. $event is an optional description of event
84 that date refers to. Possible values may include: creation,
85 publication, and modification.
86
87 add_description($description)
88 Add description of the publication content
89
90 add_format($format)
91 The media type or dimensions of the resource. Best practice is to
92 use a value from a controlled vocabulary (e.g. MIME media types).
93
94 add_language($lang)
95 Add language of the content of the publication. $lang must comply
96 with RFC 3066 (see http://www.ietf.org/rfc/rfc3066.txt)
97
98 add_relation($relation)
99 An identifier of an auxiliary resource and its relationship to the
100 publication.
101
102 add_rights($rights)
103 A statement about rights, or a reference to one. In this
104 specification, the copyright notice and any further rights
105 description should appear directly.
106
107 add_source($source)
108 Information regarding a prior resource from which the publication
109 was derived
110
111 add_subject($subject)
112 Add subject of the publication
113
114 add_translator($name, [$formal_name])
115 Add translator of the document. $name is in human-readable form,
116 e.g. "Arthur Conan Doyle", $formal_name is in form, suitable for
117 machine processing, e.g. "Doyle, Arthur Conan"
118
119 add_type($type)
120 type includes terms describing general categories, functions,
121 genres, or aggregation levels for content. The advised best
122 practice is to select a value from a controlled vocabulary.
123
124 add_navpoint(%opts)
125 Add refrence to an OPS Content Document that is a part of
126 publication. %opts is an anonymous hash, for possible key values
127 see EBook::EPUB::NCX::NavPoint. Method returns created
128 EBook::EPUB::NCX::NavPoint object that could be used later for
129 adding subsections.
130
131 add_meta_item($name, $value)
132 Add non-standard item to metadata e.g. metadata from source
133 documetn that is not described in Doublin Core spec.
134
135 add_xhtml($filename, $data, %opts)
136 Add xhtml data $data to $filename in package. Returns id of newly
137 added entry.
138
139 %opts is an anonymous hash array of parameters:
140
141 linear 'yes' or 'no'
142
143 add_stylesheet($filename, $data)
144 Add stylesheet data $data as $filename in package. Returns id of
145 newly added entry.
146
147 add_image($filename, $data, $type)
148 Add image data $data as $filename in package with content type
149 $type (e.g. image/jpeg). Returns id of newly added entry.
150
151 copy_xhtml($source_file, $filename, %opts)
152 Add existing xhtml file $source_file as $filename in package.
153 Returns id of newly added entry.
154
155 %opts is an anonymous hash array of parameters:
156
157 linear 'yes' or 'no'
158
159 copy_stylesheet($source_file, $filename)
160 Add existing css file $source_file as $filename in package. Returns
161 id of newly added entry.
162
163 copy_image($source_file, $filename, $type)
164 Add existing image file $source_file as $filename in package and
165 set its content type to $type (e.g. image/jpeg). Returns id of
166 newly added entry.
167
168 copy_file($source_file, $filename, $type)
169 Add existing file $source_file as $filename in package and set its
170 content type to $type (e.g. text/plain). Returns id of newly
171 created entry. Returns id of newly added entry.
172
173 encrypt_file($source_file, $filename, $type)
174 Add existing file $source_file as $filename in package and set its
175 content type to $type (e.g. text/plain) Apply Adobe copy protection
176 scheme to this file using book UUID as a key. Function croaks if
177 key has not been set previously using. Returns id of newly added
178 entry.
179
180 pack_zip($filename)
181 Generate OCF Zip container with contents of current package
182
184 Oleksandr Tymoshenko, <gonzo@bluezbox.com>
185
187 Please report any bugs or feature requests to <gonzo@bluezbox.com>
188
190 Copyright 2009, 2010 Oleksandr Tymoshenko.
191
192 <http://bluezbox.com>
193
194 This module is free software; you can redistribute it and/or modify it
195 under the terms of the BSD license. See the LICENSE file included with
196 this distribution.
197
198
199
200perl v5.12.1 2010-08-18 EBook::EPUB(3)