Itbaa (اطبع - Arabic for "Print") is a high-quality HTML to PDF conversion library and CLI tool built on Ladybird's rendering engine.
- Vector PDF output - Generates true vector PDFs with selectable text
- Full font support - Handles embedded fonts, base64 fonts, and system fonts
- International text - Full support for RTL languages (Arabic, Hebrew) and complex scripts
- Multi-page documents - Automatic pagination with configurable page sizes
- Full CSS support - Modern CSS including flexbox, grid, and custom properties
- C API - Easy integration with Node.js, Python, and other languages
- High Performance - 6.72x faster than Playwright, 13.86x faster than Puppeteer
Benchmark results comparing Itbaa with Playwright and Puppeteer on a simple HTML document (10 iterations):
| Tool | Time (ms) [min-max] | Binary Size |
|---|---|---|
| Itbaa | 111.66 (73.45-446.15) | 118~240 MB |
| Playwright | 717.92 (657.29-1178.56) | ~516 MB |
| Puppeteer | 1667.35 (1317.29-4559.41) | ~1.9 GB |
Itbaa is 6.43x faster than Playwright and 14.93x faster than Puppeteer with a smaller footprint (118 MB standalone vs 516 MB+ for Playwright and 1.9 GB+ for Puppeteer including Chromium). Itbaa uses Ladybird's lightweight rendering engine directly (no browser overhead) and is compiled C++ for native performance.
For building:
- macOS 14+ or Linux
- CMake 3.25+
- Ninja
- Clang/LLVM 18+
For running pre-built binaries:
-
Linux:
libatomic1,libstdc++6,libgcc-s1,fontconfig,fonts-liberation# Ubuntu/Debian sudo apt-get install libatomic1 libstdc++6 libgcc-s1 fontconfig fonts-liberation # CentOS/RHEL sudo yum install libatomic libstdc++ libgcc fontconfig liberation-fonts
-
macOS: No additional dependencies (all libraries included)
./build.sh# Convert HTML to PDF
./build/bin/itbaa document.html output.pdf
# Show document info
./build/bin/itbaa --info document.html
# Limit pages
./build/bin/itbaa -p 5 document.html output.pdf
# Custom page size
./build/bin/itbaa --size letter document.html output.pdf
./build/bin/itbaa -w 800 -h 600 document.html output.pdf| Option | Description |
|---|---|
-i, --info |
Show document info without generating PDF |
-p, --pages <N> |
Maximum number of pages (default: all) |
-w, --width <N> |
Page width in pixels (default: 794 for A4) |
-h, --height <N> |
Page height in pixels (default: 1123 for A4) |
-s, --size <SIZE> |
Page size preset: a4, letter, legal, a3 |
--no-full-page |
Don't capture full scrollable content |
--version |
Show version information |
--help |
Show help message |
#include <Itbaa.h>
int main() {
// Initialize
itbaa_init();
// Create context
ItbaaContext* ctx = itbaa_context_create();
// Load HTML
itbaa_load_html_file(ctx, "document.html");
// Convert to PDF
ItbaaOptions options = itbaa_default_options();
itbaa_convert_to_file(ctx, &options, "output.pdf");
// Cleanup
itbaa_context_destroy(ctx);
itbaa_shutdown();
return 0;
}Itbaa ensures identical PDF output regardless of which platform generates the PDF. PDFs created on macOS will look exactly the same when viewed or printed on Linux, Windows, or any other system.
-
HTML
@font-facefonts (highest priority)- Fonts specified in your HTML via
@font-facerules are automatically loaded - These take priority over all other fonts for matching
font-familynames - Supports local files, remote URLs, and base64-encoded fonts
- Fonts specified in your HTML via
-
Bundled fonts (loaded FIRST for consistency)
NotoEmoji.ttf- Emoji support (consistent across all platforms)SerenitySans-Regular.ttf- Default sans-serif font- These fonts are the same on macOS, Linux, and Windows
- By loading bundled fonts first, PDFs generated on any platform will use the same fonts
-
System fonts (loaded as fallback)
- macOS:
/System/Library/Fonts,/Library/Fonts,~/Library/Fonts - Linux: System font directories (via fontconfig or standard paths)
- Windows:
%WINDIR%\Fonts,%LOCALAPPDATA%\Microsoft\Windows\Fonts - System fonts provide additional emoji variants and fallback options
- Only used if bundled fonts don't have the required glyphs
- macOS:
Option 1: @font-face in HTML (Recommended)
<style>
@font-face {
font-family: "MyFont";
src: url("path/to/font.ttf") format("truetype");
}
body {
font-family: "MyFont", sans-serif;
}
</style>For consistent emoji rendering (Apple Color Emoji style):
<style>
@font-face {
font-family: "Apple Color Emoji";
src: url("https://github.com/samuelngs/apple-emoji-linux/releases/download/v15.4/AppleColorEmoji.ttf") format("truetype");
}
body {
font-family: -apple-system, "Apple Color Emoji", sans-serif;
}
</style>This ensures emojis look identical across all platforms (macOS-style emojis everywhere).
For static builds suitable for distribution:
./build.sh --staticUtilities/Itbaa/
├── lib/ # Core library
│ ├── Itbaa.h # Public C API
│ ├── Itbaa.cpp # C API implementation
│ ├── Renderer.h/cpp # HTML rendering engine
│ ├── PDFWriter.h/cpp # PDF generation
│ └── DisplayListPlayerPDF.h/cpp # Vector rendering
└── cli/ # CLI tool
└── main.cpp
There is a known issue with bidirectional (BiDi) text rendering in Ladybird's engine that affects Arabic, Hebrew, and other RTL languages. Text may appear with incorrect word order or spacing in some cases.
Upstream Issue: LadybirdBrowser/ladybird#7288
Itbaa is available under dual licensing:
- Apache License 2.0 - For open-source use (see LICENSE)
- Commercial License - For commercial use without open-source obligations (see COMMERCIAL_LICENSE)
For details on both licensing options, see LICENSING.md.
Commercial licensing inquiries: [email protected]
This project uses Ladybird (BSD 2-Clause) - see NOTICE for third-party attributions.
If you find Itbaa useful, consider supporting its development:
- GitHub Sponsors
- Star this repository
- Report bugs and contribute
sudorw (@ahmedrowaihi)
[email protected]
Built on Ladybird browser engine by Andreas Kling and contributors.