FB2 libraries
Open-source libraries for FictionBook 2. FB2 is plain XML, so any XML parser can read it; a dedicated library adds a typed model of the schema (title info, authors, sections, binaries), tolerates the many slightly invalid files in circulation, and handles old encodings such as windows-1251. MuPDF and PyMuPDF go further and lay out FB2 into pages for rendering or PDF conversion.
| Language | Library | Read | Write | Notes |
|---|---|---|---|---|
| C/C++ | MuPDF | yes | no | renders FB2, extracts text, converts to PDF; AGPL |
| C# | Fb2.Document | yes | yes | full DOM with querying, editing and serialization |
| C# | FB2Library | yes | yes | typed model of the FB2 schema, .NET Standard 1.0 |
| Python | PyMuPDF | yes | no | text extraction, rendering, convert to PDF; AGPL |
| Python | FB2 | no | yes | builds FB2 books from chapters, images and metadata |
| Rust | fb2 | yes | partial | serde models for quick-xml, lenient parsing |
| PHP | PHP eBook | yes | no | metadata, cover and raw body; also EPUB and MOBI |
By language#
- FB2 libraries for C/C++ Open-source C and C++ libraries for FB2 (FictionBook) e-books: MuPDF lays out, renders and extracts text from FB2 and converts it to PDF. Code examples.
- FB2 libraries for C# Open-source .NET libraries for FB2 (FictionBook) e-books: Fb2.Document and FB2Library read, edit and write FB2 files. Comparison and code examples.
- FB2 libraries for Python Open-source Python libraries for FB2 (FictionBook) e-books: PyMuPDF reads and renders FB2, the FB2 package creates FB2 books. Code examples.
- FB2 libraries for Rust Open-source Rust crate for FB2 (FictionBook) e-books: fb2 provides serde models of the FB2 schema for parsing FictionBook files with quick-xml. Code examples.
- FB2 libraries for PHP Open-source PHP library for FB2 (FictionBook) e-books: PHP eBook (kiwilan/php-ebook) reads FB2 metadata, series, cover and body. Code examples.