#What Ebooks to PDF solves
Send structured book content (metadata, chapters) and receive a professionally formatted PDF with automatic page numbering, table of contents, cover page, and annotation page. Ideal for self-publishing, manuscript generation, print-on-demand, and document archival. Supports 150+ customization options including fonts, spacing, margins that auto-adjust based on font size.
#Endpoint & when to use it
#POST https://api.yeb.to/v1/ebooks/pdf/convert-from-file
- Best for: Converting novels, short stories, manuals, reports, or any multi-chapter content into print-ready PDFs.
- How it works: We render your content using the
elegant-noveltemplate with Blade + Puppeteer/Chromium for pixel-perfect output. - Output format: High-quality A4/A5/Letter PDFs with professional typography and automatic layout.
- Processing time: ~2-5 seconds depending on content length and customization complexity.
#Quick start
Step 1: Create a JSON file with your book data and upload it to a public URL
# book.json (minimal example)
{
"template": "elegant-novel",
"metadata": {
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald"
},
"chapters": [
{
"title": "Chapter I",
"content": "In my younger and more vulnerable years..."
}
]
}
Step 2: Call the API with the file URL
curl -X POST "https://api.yeb.to/v1/ebooks/pdf/convert-from-file" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_url": "https://yourdomain.com/books/book.json"}'
#Parameters that actually matter
| Param | Required | What to pass in practice | Why it matters |
|---|---|---|---|
api_key |
Yes | Send in Authorization header: Bearer YOUR_KEY. Never expose in frontend code. |
Auth & credit tracking. |
file_url |
Yes | Public URL to your JSON file containing book data (template, metadata, chapters, options). | Avoids POST size limits for large books. |
#JSON file structure
Your JSON file at file_url must contain:
| Field | Required | What to pass | Why it matters |
|---|---|---|---|
template |
Yes | Currently only elegant-novel is supported. |
Determines the PDF layout style. |
metadata |
Yes | Object with title and author at minimum. Can include description, year, publisher, etc. |
Populates cover page and document properties. |
chapters |
Yes | Array of objects, each with title and content. Minimum 1 chapter required. |
The actual book content to render. |
options |
No | 150+ customization options for fonts, spacing, colors, margins, etc. | Fine-tune typography and layout. |
texts |
No | Override default text labels (e.g., copyright notice, publisher text). | Localization and branding. |
#Key metadata fields
| Field | Use it for | Notes |
|---|---|---|
title | Book title (required) | Shown on cover and headers. |
author | Author name (required) | Shown on cover and headers. |
description | Book blurb/synopsis | Appears on annotation page. Use \n\n for multiple paragraphs. |
subtitle | Book subtitle | Optional subtitle on cover page. |
series | Series name | Shown on cover above title. |
year | Publication year | Defaults to current year if omitted. |
publisher | Publisher name | Shown on cover footer and copyright page. |
isbn | ISBN number | Optional, shown on copyright page. |
cover_image | Cover illustration URL | Image displayed on cover page. |
| Custom fields | Genre, themes, etc. | Add any custom fields; use options.meta_fields to display them. |
#Chapter formatting
Each chapter object requires:
title— The chapter heading (e.g., "Chapter I", "Prologue").content— The chapter text. Use\n\nto separate paragraphs.
Optional chapter fields:
subtitle— Chapter subtitle (shown below chapter title).number— Chapter number (for display if usingchapter_number_format).
#Customization options that matter
#Typography & spacing
| Option | Default | Use case |
|---|---|---|
chapter_content_font_size | 12pt | Main text size. Margins auto-adjust when changed (14pt, 16pt, etc.). |
chapter_content_line_height | 1.6 | Line spacing. Higher values (1.8, 2.0) improve readability. |
chapter_title_font_size | 28pt | Chapter heading size. |
chapter_content_text_indent | 15pt | First line indent for paragraphs. |
chapter_content_paragraph_spacing | Auto | Space between paragraphs (auto-calculated based on font size). |
#Page format & orientation
| Option | Values | Use case |
|---|---|---|
format | A4, A5, Letter | Page size. A4 is default (210×297mm). |
orientation | portrait, landscape | Page orientation. Portrait is default. |
#Custom metadata fields
Display additional information on the annotation page:
"metadata": {
"title": "My Book",
"author": "Jane Doe",
"genre": "Science Fiction",
"themes": "AI, humanity, future",
"language_name": "English"
},
"options": {
"meta_fields": [
{"key": "genre", "label": "Genre"},
{"key": "themes", "label": "Themes"},
{"key": "language_name", "label": "Language"}
]
}
Any field in metadata can be displayed by adding it to meta_fields.
#Toggle sections on/off
| Option | Default | Description |
|---|---|---|
include_cover | true | Show cover page with title, author, publisher. |
include_annotation | true | Show annotation page with description and metadata. |
include_copyright | true | Show copyright page at the end. |
chapter_show_title | true | Show chapter titles. |
chapter_show_header | true | Show running headers on chapter pages. |
#Reading & acting on responses
{
"success": true,
"pdf_url": "https://yeb.to/storage/ebooks/ebook_abc123.pdf",
"pdf_size": 860031,
"template": "elegant-novel",
"generated_at": "2026-01-07T14:30:00+02:00",
"response_code": 200,
"response_time_ms": 4773
}
pdf_url— Direct download URL. Files are kept for 24 hours, then auto-deleted.pdf_size— File size in bytes. Useful for bandwidth estimation.template— Template used for generation (currently onlyelegant-novel).generated_at— ISO 8601 timestamp. Use for cache invalidation or logging.response_time_ms— Processing time. Typically 2-5 seconds for standard books.
#Typical errors & how to fix
{ "error": "Metadata field 'title' is required", "response_code": 400 }
{ "error": "At least one chapter is required", "response_code": 400 }
{ "error": "Template 'unknown' not found", "response_code": 404 }
- 400 validation error: Check that
metadata.title,metadata.author, and at least onechapterare provided. - 401 invalid key: Verify your API key is correct and has sufficient credits.
- 404 template not found: Use
elegant-novelas the template name. - 500 generation failed: Check for malformed JSON or extremely large content. Contact support if persists.
#Troubleshooting & field notes
- File URL not accessible: Ensure your JSON file is publicly accessible (no auth required). Test by opening the URL in a browser - it should download/display the JSON. Check CORS headers if serving from a different domain.
- Invalid JSON format: Validate your JSON file before uploading. Use a JSON validator or
jqto check syntax. Common errors: trailing commas, unquoted keys, smart quotes instead of straight quotes. - Text overlaps page numbers: The API auto-adjusts margins based on
chapter_content_font_size. If using very large fonts (>20pt), verify the output. Margins scale automatically: 12pt = 22mm bottom, 16pt = 27mm bottom, 20pt = 32mm bottom. - Fonts not loading: Ensure
options.include_fontsis true (default). For custom fonts, useoptions.custom_fontswith Google Fonts URLs. - Paragraphs not separating: Use
\n\n(double newline) in chapter content to separate paragraphs, not single\n. - Custom metadata not showing: Add the field to both
metadataobject ANDoptions.meta_fieldsarray with matchingkey. - Processing timeout: Very long books (>500 pages) may timeout. Processing time: 10-50 pages = 5-15s, 50-200 pages = 30-60s, 200-500 pages = 2-3 minutes. Consider splitting into volumes if needed.
- PDF file expires: PDFs are auto-deleted after 24 hours. Download immediately after generation or store on your own CDN.
- Inconsistent spacing: Use the same
chapter_content_line_heightvalue for all requests to maintain consistency across documents.
#Best practices
- Host JSON files reliably: Use a CDN or reliable hosting for your JSON files. Ensure files remain accessible for the duration of the API call (2-3 minutes for large books).
- Validate JSON before upload: Use a JSON validator to catch syntax errors. Invalid JSON will fail immediately with a 400 error.
- Use descriptive filenames: Name files clearly (e.g.,
book-{id}-{timestamp}.json) for easier debugging and tracking. - Cache responses: Same file_url = same output. Cache PDF URLs for 24h to avoid regenerating identical documents.
- Pre-validate content: Check for required fields (
title,author, chapters) before creating JSON files. - Use consistent font sizes: Pick one base font size (12pt, 14pt, or 16pt) for your brand and stick with it across all books.
- Store original JSON: Keep the JSON file for regeneration if needed. PDFs expire after 24h but JSON can be reused indefinitely.
- Test with real content: Short test chapters may not reveal pagination issues. Use realistic chapter lengths (2000+ words).
- Monitor response times: Small books: 5-15s, Medium: 30-60s, Large: 2-3 minutes. If consistently slower, check file_url accessibility.
- Handle 5xx errors gracefully: Implement retry logic with exponential backoff (wait 5s, then 10s, then 20s) for server errors.
#Real-world examples
Example 1: Self-publishing platform
Create mystery-novel.json:
{
"template": "elegant-novel",
"metadata": {
"title": "Murder on the Orient Express",
"author": "Agatha Christie",
"series": "Hercule Poirot Mysteries",
"description": "A luxurious train journey turns deadly...",
"year": 1934,
"publisher": "Collins Crime Club",
"genre": "Mystery",
"themes": "Murder, investigation, justice"
},
"chapters": [
{"title": "Part I: The Facts", "content": "It was five o'clock on a winter's morning..."},
{"title": "Part II: The Evidence", "content": "In a small room..."}
],
"options": {
"format": "A5",
"chapter_content_font_size": "11pt",
"meta_fields": [
{"key": "genre", "label": "Genre"},
{"key": "themes", "label": "Themes"}
]
}
}
Call API:
curl -X POST "https://api.yeb.to/v1/ebooks/pdf/convert-from-file" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_url": "https://yourdomain.com/books/mystery-novel.json"}'
Example 2: Technical manual with custom branding
Create tech-manual.json:
{
"template": "elegant-novel",
"metadata": {
"title": "Product Installation Guide",
"author": "TechCorp Engineering",
"publisher": "TechCorp Inc.",
"year": 2026
},
"chapters": [
{"title": "1. System Requirements", "content": "Before installation..."},
{"title": "2. Installation Steps", "content": "Follow these steps..."},
{"title": "3. Troubleshooting", "content": "If you encounter issues..."}
],
"options": {
"chapter_content_font_size": "12pt",
"include_annotation": false,
"chapter_show_number": true
},
"texts": {
"copyright_text": "© {year} TechCorp Inc. All rights reserved.",
"chapter_number_format": "Section {n}"
}
}
Call API:
curl -X POST "https://api.yeb.to/v1/ebooks/pdf/convert-from-file" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_url": "https://yourdomain.com/manuals/tech-manual.json"}'
#API Changelog
chapter_content_font_size.
Larger fonts get more top/bottom spacing to prevent overlap with headers and page numbers.
Fixed: Text no longer overlaps page numbers on multi-page chapters.
options.meta_fields to display custom metadata on annotation page.
Fixed: Custom metadata fields (genre, themes, etc.) now properly render when specified.
elegant-novel template. Support for cover page, annotation page,
automatic page numbering, and copyright page.