fqqtya
Last Updated: February 25, 2016
·
1.885K
· santex
Datax

code a E-book (kindle) with perl

use EBook::EPUB;
 my $epub = EBook::EPUB->new;

 # Set metadata: title/author/language/id
 $epub->add_title('MICRO-STRUCTERS');
 $epub->add_author('santex@cpan.org');
 $epub->add_language('en');
 $epub->add_identifier('1440465908', 'ISBN');


 $epub->copy_stylesheet('/var/www/lib/css/style.css',
                        'style.css');

 $epub->copy_file('/var/www/lib/image/am3.png','am3.png',
                  'image/png');

 $epub->encrypt_file('/var/www/lib/css/fonts/League_Gothic-webfont.ttf',
                     'League_Gothic-webfont.ttf',
                     'application/x-font-ttf');


 my $chapter_id  = $epub->copy_xhtml('/var/www/micro-wiki.html',
                                     'micro-wiki.html');

  #$epub->copy_xhtml('/var/www/notes.xhtml',
  #'notes.xhtml',linear => 'no');

 # Add top-level nav-point
 my $navpoint = $epub->add_navpoint(
         label       => "Chapter 1",
         id          => $chapter_id,
         content     => 'micro-git',
         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('/var/www/lib/image/artee.png', 'cover.jpg');
 $epub->add_meta_item('cover', $cover_id);

 # Generate resulting ebook
 $epub->pack_zip('/var/www/three_men_in_a_boat.epub');
Say Thanks
Respond