PDB (Palm Database eBook: PalmDOC, eReader)
| Full name | Palm Database (PalmDOC, eReader and other Palm eBooks) |
|---|---|
| Extensions | .pdb (also .prc for the same container holding resources or Mobipocket books) |
| MIME type | application/vnd.palm, application/x-palm-database |
| Type | eBook in a database container: a header plus a list of records |
| Starts with | 32-byte database name; identify it by the type and creator at offset 60, e.g. TEXtREAd (PalmDOC), PNRdPPrs (eReader) |
| Specification | none official for PalmDOC; MobileRead wiki: PDB and PalmDOC |
| Maintained by | nobody (Palm OS was discontinued in 2009) |
| License | open, unencumbered (PalmDOC); eReader is proprietary |
A Palm Database (PDB) file is the on-disk form of a Palm OS database: a 78-byte header, a list of records and the record data. Palm eBook readers stored books this way. PalmDOC (also called AportisDoc or just “Doc”) is the common, simple one: plain text split into 4 KB records, usually compressed with a small LZ77 variant. eReader (formerly Peanut Press / Palm Reader) uses the same container with its own PML markup, images and often DRM.
The .pdb extension also names unrelated formats. A Microsoft Program Database (.pdb) holds debugging symbols for Windows programs, and a Protein Data Bank file (.pdb) is a text format for 3D molecular structures. This page is about Palm eBooks.
When to use PDB#
- Use to read or convert old PalmDOC and eReader books, or to make plain-text books for old Palm devices.
- Avoid for new books: PalmDOC has no formatting, images or metadata beyond a title. Use EPUB instead.
- Avoid eReader files with DRM: only the original eReader software with the buyer’s name and credit card number unlocks them.
File structure#
All integers are big-endian. A file is a header, a record list and then the records.
Header (78 bytes)#
| Offset | Size | Field |
|---|---|---|
| 0 | 32 | database name, zero-terminated (usually the book title) |
| 32 | 2 | attributes (0x0002 read-only, 0x0008 backup, …) |
| 34 | 2 | version |
| 36 | 4 | creation date |
| 40 | 4 | modification date |
| 44 | 4 | last backup date |
| 48 | 4 | modification number |
| 52 | 4 | offset of the AppInfo block (0 if none) |
| 56 | 4 | offset of the SortInfo block (0 if none) |
| 60 | 4 | type, e.g. TEXt |
| 64 | 4 | creator, e.g. REAd |
| 68 | 4 | unique ID seed |
| 72 | 4 | next record list ID (always 0 in files) |
| 76 | 2 | number of records N |
Dates are seconds since 1904-01-01 (unsigned). Some tools wrote seconds since 1970-01-01 instead; if the top bit is clear, assume the 1970 epoch.
Record list#
After the header come N entries of 8 bytes, then usually 2 zero bytes of padding, then the record data:
| Size | Field |
|---|---|
| 4 | offset of the record data from the start of the file |
| 1 | attributes (low 4 bits: category) |
| 3 | unique ID |
A record’s length is the next record’s offset minus its own offset (the last record runs to the end of the file).
Type and creator codes#
The 8 bytes at offset 60 tell you what the file contains:
| Format | Type | Creator |
|---|---|---|
| PalmDOC | TEXt |
REAd |
| TealDoc | TEXt |
TlDc |
| eReader | PNRd |
PPrs |
| Plucker | Data |
Plkr |
| zTXT (Weasel Reader) | zTXT |
GPlm |
| Mobipocket (MOBI) | BOOK |
MOBI |
| iSilo | ToGo |
ToGo |
PalmDOC#
Record 0 is a 16-byte header; records 1 to n hold the text; optional records after the text hold bookmarks.
| Offset | Size | Field |
|---|---|---|
| 0 | 2 | compression: 1 = none, 2 = PalmDOC LZ77 |
| 2 | 2 | unused (0) |
| 4 | 4 | uncompressed length of the whole text |
| 8 | 2 | number of text records |
| 10 | 2 | maximum record size, always 4096 |
| 12 | 4 | current reading position |
Each text record decompresses to at most 4096 bytes, independently of the others. The text has no defined encoding: it’s usually Windows-1252 (Latin-1), sometimes another 8-bit code page.
4D 79 20 42 6F 6F 6B 00 ... name "My Book", zero-padded to 32 bytes
00 00 00 00 attributes, version
... 3 dates, modnum, appinfo, sortinfo
54 45 58 74 52 45 41 64 type "TEXt", creator "REAd" (offset 60)
00 00 00 00 00 00 00 00 unique ID seed, next record list
00 05 5 records (offset 76)
00 00 00 A0 00 00 00 00 record 0 at offset 0xA0
... records 1-4
-- record 0 --
00 02 00 00 compression 2 (PalmDOC), unused
00 00 3A 98 text length 15000
00 04 10 00 4 text records, record size 4096
00 00 00 00 current position
PalmDOC compression#
A simple LZ77 variant. Read the compressed record byte by byte:
| Byte | Meaning |
|---|---|
0x00, 0x09-0x7F |
copy this byte to the output |
0x01-0x08 |
copy the next 1-8 bytes as they are |
0x80-0xBF |
with the next byte forms 16 bits: drop the top 2 bits, then 11 bits of distance back and 3 bits of length (length + 3 = 3 to 10 bytes) |
0xC0-0xFF |
a space followed by the character byte XOR 0x80 |
It saves roughly 40% on English text, much less than zlib (zTXT books save about 70%). The same compression is used in MOBI and AZW files.
eReader#
eReader files (PNRd/PPrs) have a record 0 with a compression field: 2 (PalmDOC), 10 (zlib), and 260 or 272 for DRM-protected books. The text is in PML (Palm Markup Language), with tags like \p (page break), \x (chapter), \b (bold). Images are stored as PNG records. Unprotected eReader books can be converted with calibre.
Specifications and documentation#
There is no official PalmDOC specification. These are the references every implementation uses:
- PDB on the MobileRead wiki: header, record list, type/creator codes
- PalmDOC on the MobileRead wiki: record 0 and the compression algorithm
- eReader on the MobileRead wiki and PML
- calibre PDB readers and writers: PalmDOC, eReader, zTXT, Plucker (Python)
- Palm OS PDB on Wikipedia
Software that opens PDB files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; PalmDOC books | |||
| calibre | ✓ | ✓ | ✓ | view, convert, create | free, open source; reads PalmDOC, eReader, zTXT, Plucker; writes PalmDOC, eReader, zTXT | |
| KOReader | ✓ | view | free, open source; e-ink readers (Kindle, Kobo, PocketBook) and Android. Also on Android | |||
| CoolReader | ✓ | ✓ | view | free, open source. Also on Android | ||
| txt2pdbdoc | ✓ | ✓ | convert, create | command line; text to PalmDOC and back | ||
| CloudConvert | ✓ | convert | online converter, free tier |
Libraries#
Libraries for the PDB container and PalmDOC compression exist for a few languages. See all PDB libraries.
| C/C++ | pilot-link |
|---|---|
| Go | pdb |
| Rust | palmdoc-compression |