Git Product home page Git Product logo

epub2pdf's Introduction

Instruction to Setup

  1. conda env create -f environment.yml or pip install -r requirements.txt
  2. source activate epub

Epub2pdf

  1. python epub2pdf.py "{filepath}"
  2. It will generate {filename}.pdf in current directory

Mobi2PDf

  1. python mobi2pdf.pf "{filepath}"
  2. It will generate {filename}.pdf in current directory

Known Bugs

  1. Pdf Outline issues.
  2. page change for each chapter.

How it works [Epub]

  1. Epub is zipped file containing xhtml and metadata.
  2. So I used weasyprint to convert xhtml to pdf.
  3. But how to know which html to add first.
  4. That information is contained in *.ncx inside epub bundle. BS4 is used to read ncx file.

How it works [Mobi]

  1. Kindle unpack to extract data.
  2. Weasyprint to convert html to pdf.

Credits

  1. KindleUnpack
  2. Weasyprint

epub2pdf's People

Contributors

rava-dosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

epub2pdf's Issues

Error while trying to convert file.

Traceback (most recent call last): File "epub2pdf.py", line 2, in <module> from weasyprint import HTML, CSS, default_url_fetcher File "D:\StudyMaterial\converter\converter\lib\site-packages\weasyprint\__init__.py", line 440, in <module> from .css import preprocess_stylesheet # noqa isort:skip File "D:\StudyMaterial\converter\converter\lib\site-packages\weasyprint\css\__init__.py", line 30, in <module> from . import computed_values, media_queries File "D:\StudyMaterial\converter\converter\lib\site-packages\weasyprint\css\computed_values.py", line 18, in <module> from .. import text File "D:\StudyMaterial\converter\converter\lib\site-packages\weasyprint\text.py", line 14, in <module> import cairocffi as cairo File "D:\StudyMaterial\converter\converter\lib\site-packages\cairocffi\__init__.py", line 50, in <module> ('libcairo.so', 'libcairo.2.dylib', 'libcairo-2.dll')) File "D:\StudyMaterial\converter\converter\lib\site-packages\cairocffi\__init__.py", line 45, in dlopen raise OSError(error_message) # pragma: no cover OSError: no library called "cairo" was found no library called "libcairo-2" was found cannot load library 'libcairo.so': error 0x7e cannot load library 'libcairo.2.dylib': error 0x7e cannot load library 'libcairo-2.dll': error 0x7e

Required visual c++ 14.0 , but i already installed, so what was the issue

Using cached cffi-1.14.0.tar.gz (463 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\users\mohan\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\mohan\AppData\Local\Temp\pip-install-2voalm_6\cffi\setup.py'"'"'; file='"'"'C:\Users\mohan\AppData\Local\Temp\pip-install-2voalm_6\cffi\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\mohan\AppData\Local\Temp\pip-pip-egg-info-j_9yj88w'
cwd: C:\Users\mohan\AppData\Local\Temp\pip-install-2voalm_6\cffi
Complete output (19 lines):
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\mohan\AppData\Local\Temp\pip-install-2voalm_6\cffi\setup.py", line 127, in
if sys.platform == 'win32' and uses_msvc():
File "C:\Users\mohan\AppData\Local\Temp\pip-install-2voalm_6\cffi\setup.py", line 105, in uses_msvc
return config.try_compile('#ifndef _MSC_VER\n#error "not MSVC"\n#endif')
File "c:\users\mohan\appdata\local\programs\python\python39\lib\distutils\command\config.py", line 225, in try_compile
self._compile(body, headers, include_dirs, lang)
File "c:\users\mohan\appdata\local\programs\python\python39\lib\distutils\command\config.py", line 132, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "c:\users\mohan\appdata\local\programs\python\python39\lib\distutils_msvccompiler.py", line 323, in compile
self.initialize()
File "c:\users\mohan\appdata\local\programs\python\python39\lib\distutils_msvccompiler.py", line 220, in initialize
vc_env = _get_vc_env(plat_spec)
File "c:\users\mohan\appdata\local\programs\python\python39\lib\site-packages\setuptools\msvc.py", line 314, in msvc14_get_vc_env
File "c:\users\mohan\appdata\local\programs\python\python39\lib\site-packages\setuptools\msvc.py", line 268, in _msvc14_get_vc_env
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

When img_jpg has no prefix path, a wrong path is generated

Logs

given

img_jpg= Image00000.jpg
global_root_dir=/tmp/epub_temp/OEBPS/

after

image_base=global_root_dir+img_jpg.split("/")[0]+"/"

we have:

img_base=/tmp/epub_temp/OEBPS/Image00000.jpg/

this is not an expected img_base.

Analysis

unexpected condition:

when img_jpg= Image00000.jpg, img_jpg.split("/")[0] returns Image00000.jpg

This logic only works in such a way:

when img_jpg= my_img/Image00000.jpg, img_jpg.split("/")[0] returns my_img

cairo dependency problem

Traceback (most recent call last):
File "D:/IdeaProjects/book2txt/mobi2pdf/mobi2pdf.py", line 2, in
from weasyprint import HTML, CSS, default_url_fetcher
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\weasyprint_init_.py", line 440, in
from .css import preprocess_stylesheet # noqa isort:skip
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\weasyprint\css_init_.py", line 30, in
from . import computed_values, media_queries
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\weasyprint\css\computed_values.py", line 18, in
from .. import text
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\weasyprint\text.py", line 14, in
import cairocffi as cairo
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\cairocffi_init_.py", line 48, in
cairo = dlopen(
File "D:\IdeaProjects\book2txt\venv1\lib\site-packages\cairocffi_init_.py", line 45, in dlopen
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo" was found
cannot load library 'C:\Program Files\GTK3-Runtime Win64\bin\libcairo-2.dll': error 0xc1
cannot load library 'libcairo.so': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0xc1

one problem

Can I please ask where "/tmp/weasyprint.log" is?

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.