Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
EPUB is an open XML-based format for digital books and publications designed for optimal viewing on various devices. It is created by International Digital Publishing Forum ( IDPF), and now it is supported by many e-readers and software applications. EPUB to PDF conversion is often required to take advantage of PDF format. With Aspose.HTML for Python via .NET, you can convert EPUB to PDF programmatically with full control over a wide range of conversion parameters.
In this article, you find information on how to convert EPUB to PDF using convert_epub() methods of the Converter class and how to apply PdfSaveOptions.
To continue following this tutorial, install and configure Aspose.HTML for Python via .NET in your Python project.
You can check the Aspose.HTML for Python via .NET API functionality and convert EPUB in real-time. Please load an EPUB file from a local file system or URL, select the output format and run the example. In the example, the save options are set by default. You will immediately receive the result as a separate file.
If you want to convert EPUB to PDF using PdfSaveOptions programmatically, please see the following Python code example.
Using convert_epub() methods is the most common way to convert EPUB files into various formats. To convert EPUB to PDF, you should follow a few steps:
PdfSaveOptions, and output file path to the convert_epub().The following example shows how to use PdfSaveOptions and create a PDF file with custom save options:
1# Convert EPUB to PDF using Python with custom settings
2
3import os
4import aspose.html.converters as conv
5import aspose.html.saving as sav
6import aspose.html.drawing as dr
7
8# Setup directories and define paths
9output_dir = "output/"
10input_dir = "data/"
11os.makedirs(output_dir, exist_ok=True)
12
13document_path = os.path.join(input_dir, "input.epub")
14save_path = os.path.join(output_dir, "epub-to-pdf.pdf")
15
16# Open an existing EPUB file for reading
17with open(document_path, "rb") as stream:
18
19 # Create an instance of PdfSaveOptions
20 options = sav.PdfSaveOptions()
21 options.page_setup.any_page = dr.Page(dr.Size(800, 600), dr.Margin(10, 10, 10, 10))
22 options.css.media_type.PRINT
23
24 # Convert EPUB to PDF
25 conv.Converter.convert_epub(stream, options, save_path)In the example, we open and read source files from the file system at the specified path. The PdfSaveOptions() constructor initializes an instance of the PdfSaveOptions class that is passed to convert_epub() method that takes the stream, options, output file path save_path and performs the conversion operation. The PdfSaveOptions class provides numerous properties that give you full control over a wide range of parameters and improve the process of converting EPUB to PDF format. In the example, we use the page_setup and css.media_type properties.
Aspose.HTML for Python via .NET provides the
PdfSaveOptions class, which gives you more control over how documents are saved in PDF format. Some properties of this class inherit properties of base classes, such as
PdfRenderingOptions or RenderingOptions. Here is a description of properties available in PdfSaveOptions:
CssOptions object to configure the processing of CSS properties during HTML to PDF conversion. It allows precise control over how styles from the HTML are interpreted and applied in the resulting PDF.See Also
Download the Aspose.HTML for Python via .NET library to successfully, quickly, and easily convert your HTML, MHTML, EPUB, SVG, and Markdown documents to the most popular formats.
You can download the complete examples and data files from GitHub.
Aspose.HTML offers a free online EPUB to PDF Converter that converts EPUB to PDF with high quality, easy and fast. Just upload, convert your files and get results in a few seconds!
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.