E-Book MCP Server with PDF Conversion
by rmcendarfer2017
A server for creating e-books and PDF documents from HTML content with embedded images. This project provides robust functionality for converting HTML files to PDF while properly handling embedded images.
Last updated: N/A
What is E-Book MCP Server with PDF Conversion?
This server provides a way to convert HTML files, including embedded images, into PDF documents. It supports multiple PDF generation engines and includes error handling and temporary file management.
How to use E-Book MCP Server with PDF Conversion?
To use the server, clone the repository, install the required Python packages (fastapi, python-docx, pdfkit, reportlab, pydantic, uvicorn, pillow), and optionally install wkhtmltopdf for better PDF quality. Then, call the handle_call_tool
function with the path to the HTML file, image paths, and the desired output PDF path.
Key features of E-Book MCP Server with PDF Conversion
Convert HTML files to PDF documents with proper image handling
Support for both pdfkit (wkhtmltopdf) and reportlab PDF generation engines
Robust error handling and logging
Temporary file management with automatic cleanup
Detailed diagnostic information during conversion process
Use cases of E-Book MCP Server with PDF Conversion
Generating reports from HTML templates
Creating e-books from HTML content
Converting web pages to PDF format
Automating document creation workflows
FAQ from E-Book MCP Server with PDF Conversion
What is wkhtmltopdf and why is it recommended?
What is wkhtmltopdf and why is it recommended?
wkhtmltopdf is an open-source command-line tool that renders HTML into PDF using the Qt WebKit rendering engine. It's recommended because it often produces higher-quality PDFs compared to reportlab.
What happens if pdfkit fails?
What happens if pdfkit fails?
If pdfkit fails or is not available, the server falls back to using reportlab to generate the PDF.
What image formats are supported?
What image formats are supported?
The server supports common image formats like PNG and JPG, as demonstrated in the example. Other formats supported depend on the underlying libraries (Pillow, reportlab).
How are images handled during conversion?
How are images handled during conversion?
The server replaces image references in the HTML with absolute paths to ensure they are properly embedded in the PDF.
Is there any error handling?
Is there any error handling?
Yes, the server includes robust error handling and logging to help diagnose and resolve issues during the conversion process.