GithubHelp home page GithubHelp logo

mashu3 / epub2pdf Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 24 KB

This is a Python script for converting fixed-layout manga/comic files(epub, azw3, mobi) to PDF file.

License: GNU General Public License v3.0

Python 100.00%
epub azw3 mobi pdf-converter

epub2pdf's Introduction

epub2pdf

Overview

This is a Python script for converting fixed-layout EPUB/MOBI files such as comics and manga to PDF file, which can be executed from the command line with some arguments. This Python script only supports DRM-free EPUB/MOBI files of a specific format.

Requirement

The script uses the Python libraries img2pdf and pikepdf to do the conversion. Moreover, it uses lxml to read the EPUB files and mobi to handle both MOBI and AZW files.

It requires the installation of these packages in order to work properly.

Usage

The program can be executed from the command line with the following options:

  • The input_path argument is the path to the input file. To execute the Python script correctly, specify the input_path argument as the path to the input file containing manga or comic images in one of the supported formats, such as epub, mobi, or azw.
  • The output_path argument is the path to the output PDF file. To use the script, simply run the Python script with the path to the input EPUB file as the argument. If the --output option is not specified, the output file name will be generated from the input EPUB file name.
  • The pagelayout argument is the page layout of the PDF file. The pagelayout parameter can take in the following values:
    • SinglePage -> Single page display
    • OneColumn -> Enable scrolling
    • TwoPageLeft -> Spread view
    • TwoColumnLeft -> Spread view with scrolling
    • (default) TwoPageRight -> Separate Cover, Spread View
    • TwoColumnRight -> Separate Cover, Scrolling Spread View
  • The direction argument is the reading direction of the PDF file. The direction parameter can take in the following values:
    • L2R -> Left Binding
    • (default) R2L -> Right Binding

By default, the page layout is set to TwoPageRight and the reading direction to R2L, which are suitable for Japanese manga.

There is a possibility that the script will not run correctly if an unexpected EPUB format is encountered, as the script may not be able to handle it correctly.

Installing directly from the Git repository

To install the package directly from the Git repository, run the following command:

$ pip install git+https://github.com/mashu3/epub2pdf.git

Installing by cloning the Git repository

To install the package by cloning the Git repository, follow these steps:

$ git clone https://github.com/mashu3/epub2pdf.git
$ cd epub2pdf/
$ pip install .

Examples

  • To convert my_manga.epub to my_manga.pdf using the default settings:

    $ python epub2pdf.py my_manga.epub

  • To convert my_manga.epub to my_manga_spread.pdf with a spread view and right binding:

    $ python epub2pdf.py my_manga.epub -o my_manga_spread.pdf

  • To convert my_comic.epub to my_comic.pdf with a TwoPage view and left binding:

    $ python epub2pdf.py my_comic.epub -o my_comic.pdf -p TwoPageLeft -d L2R

Once the arguments are given, the program will convert the EPUB file to PDF.

Credits

KindleUnpack

Author

mashu3

Authors

epub2pdf's People

Contributors

mashu3 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

hp0404

epub2pdf's Issues

issue with file

epub2pdf 9781098108298.epub
Traceback (most recent call last):
  File "/home/xsazcd/git/obar1/0to100.oreilly.git/.venv/bin/epub2pdf", line 33, in <module>
    sys.exit(load_entry_point('epub2pdf==0.1.0', 'console_scripts', 'epub2pdf')())
  File "/home/xsazcd/git/obar1/0to100.oreilly.git/.venv/lib/python3.10/site-packages/epub2pdf.py", line 258, in main
    converter.convert()
  File "/home/xsazcd/git/obar1/0to100.oreilly.git/.venv/lib/python3.10/site-packages/epub2pdf.py", line 156, in convert
    page_index = self.extract_epub_index(epub, page_names, ncx_name)
  File "/home/xsazcd/git/obar1/0to100.oreilly.git/.venv/lib/python3.10/site-packages/epub2pdf.py", line 107, in extract_epub_index
    index_number = page_names.index(nav_text)
ValueError: 'OEBPS/preface01.xhtml#preface_idQ8pGjx' is not in list

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.