-
-
18 Aug 2010 21:40:28 UTC
- Distribution: EBook-EPUB
- Module version: 0.5
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (0)
- Testers (849 / 5 / 0)
- Kwalitee
Bus factor: 0- License: bsd
- Activity
24 month- Tools
- Download (14.88KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Archive::Zip
- Carp
- Data::UUID
- File::Copy
- File::Find
- File::Temp
- Moose
- Test::More
- XML::Writer
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
EBook::EPUB - module for generating EPUB documents
VERSION
Version 0.5
SYNOPSIS
use EBook::EPUB; # Create EPUB object my $epub = EBook::EPUB->new; # Set metadata: title/author/language/id $epub->add_title('Three Men in a Boat'); $epub->add_author('Jerome K. Jerome'); $epub->add_language('en'); $epub->add_identifier('1440465908', 'ISBN'); # Add package content: stylesheet, font, xhtml and cover $epub->copy_stylesheet('/path/to/style.css', 'style.css'); $epub->copy_file('/path/to/figure1.png', 'figure1.png', 'image/png'); $epub->encrypt_file('/path/to/CharisSILB.ttf', 'CharisSILB.ttf', 'application/x-font-ttf'); my $chapter_id = $epub->copy_xhtml('/path/to/page1.xhtml', 'page1.xhtml'); $epub->copy_xhtml('/path/to/notes.xhtml', 'notes.xhtml', linear => 'no' ); # Add top-level nav-point my $navpoint = $epub->add_navpoint( label => "Chapter 1", id => $chapter_id, content => 'page1.xhtml', play_order => 1 # should always start with 1 ); # Add cover image # Not actual epub standart but does the trick for iBooks my $cover_id = $epub->copy_image('/path/to/cover.jpg', 'cover.jpg'); $epub->add_meta_item('cover', $cover_id); # Generate resulting ebook $epub->pack_zip('/path/to/three_men_in_a_boat.epub');
SUBROUTINES/METHODS
- new([$params])
-
Create an EBook::EPUB object
- add_title($title)
-
Set the title of the book
- add_identifier($id, [$scheme])
-
Set a unique identifier for the book, such as its ISBN or a URL
- add_author($name, [$formal_name])
-
Add author of the document. For details see add_contributor.
- add_creator($name, [fileas => $formal_name, role => $role])
-
Add primary creator or author of the publication of the publication. See add_contributor for details
- add_contributor($name, [fileas => $formal_name, role =>])
-
Add person/organization that contributed to publication. $name is the name in human-readable form, e.g. "Arthur Conan Doyle", $formal_name is in form, suitable for machine processing, e.g. "Doyle, Arthur Conan". $role reflects kind of contribution to document. See Section 2.2.6 of OPF specification for list of possible values http://www.idpf.org/2007/opf/OPF_2.0_final_spec.html#Section2.2.6
- add_date($date, [$event])
-
Date of publication, in the format defined by "Date and Time Formats" at http://www.w3.org/TR/NOTE-datetime and by ISO 8601 on which it is based. In particular, dates without times are represented in the form YYYY[-MM[-DD]]: a required 4-digit year, an optional 2-digit month, and if the month is given, an optional 2-digit day of month. $event is an optional description of event that date refers to. Possible values may include: creation, publication, and modification.
- add_description($description)
-
Add description of the publication content
- add_format($format)
-
The media type or dimensions of the resource. Best practice is to use a value from a controlled vocabulary (e.g. MIME media types).
- add_language($lang)
-
Add language of the content of the publication. $lang must comply with RFC 3066 (see http://www.ietf.org/rfc/rfc3066.txt)
- add_relation($relation)
-
An identifier of an auxiliary resource and its relationship to the publication.
- add_rights($rights)
-
A statement about rights, or a reference to one. In this specification, the copyright notice and any further rights description should appear directly.
- add_source($source)
-
Information regarding a prior resource from which the publication was derived
- add_subject($subject)
-
Add subject of the publication
- add_translator($name, [$formal_name])
-
Add translator of the document. $name is in human-readable form, e.g. "Arthur Conan Doyle", $formal_name is in form, suitable for machine processing, e.g. "Doyle, Arthur Conan"
- add_type($type)
-
type includes terms describing general categories, functions, genres, or aggregation levels for content. The advised best practice is to select a value from a controlled vocabulary.
- add_navpoint(%opts)
-
Add refrence to an OPS Content Document that is a part of publication. %opts is an anonymous hash, for possible key values see EBook::EPUB::NCX::NavPoint. Method returns created EBook::EPUB::NCX::NavPoint object that could be used later for adding subsections.
- add_meta_item($name, $value)
-
Add non-standard item to metadata e.g. metadata from source documetn that is not described in Doublin Core spec.
- add_xhtml($filename, $data, %opts)
-
Add xhtml data $data to $filename in package. Returns id of newly added entry.
%opts is an anonymous hash array of parameters:
- linear
-
'yes' or 'no'
- add_stylesheet($filename, $data)
-
Add stylesheet data $data as $filename in package. Returns id of newly added entry.
- add_image($filename, $data, $type)
-
Add image data $data as $filename in package with content type $type (e.g. image/jpeg). Returns id of newly added entry.
- copy_xhtml($source_file, $filename, %opts)
-
Add existing xhtml file $source_file as $filename in package. Returns id of newly added entry.
%opts is an anonymous hash array of parameters:
- linear
-
'yes' or 'no'
- copy_stylesheet($source_file, $filename)
-
Add existing css file $source_file as $filename in package. Returns id of newly added entry.
- copy_image($source_file, $filename, $type)
-
Add existing image file $source_file as $filename in package and set its content type to $type (e.g. image/jpeg). Returns id of newly added entry.
- copy_file($source_file, $filename, $type)
-
Add existing file $source_file as $filename in package and set its content type to $type (e.g. text/plain). Returns id of newly created entry. Returns id of newly added entry.
- encrypt_file($source_file, $filename, $type)
-
Add existing file $source_file as $filename in package and set its content type to $type (e.g. text/plain) Apply Adobe copy protection scheme to this file using book UUID as a key. Function croaks if key has not been set previously using. Returns id of newly added entry.
- pack_zip($filename)
-
Generate OCF Zip container with contents of current package
AUTHOR
Oleksandr Tymoshenko, <gonzo@bluezbox.com>
BUGS
Please report any bugs or feature requests to <gonzo@bluezbox.com>
LICENSE AND COPYRIGHT
Copyright 2009, 2010 Oleksandr Tymoshenko.
This module is free software; you can redistribute it and/or modify it under the terms of the BSD license. See the LICENSE file included with this distribution.
Module Install Instructions
To install EBook::EPUB, copy and paste the appropriate command in to your terminal.
cpanm EBook::EPUB
perl -MCPAN -e shell install EBook::EPUB
For more information on module installation, please visit the detailed CPAN module installation guide.