parseAzw4Book function
Parses an AZW4 PalmDB/MOBI wrapper by extracting and delegating its PDF payload to the existing PDF reader.
The returned PdfBook keeps BookFormat.azw4 in both the book and its metadata, while PdfBook.bytes contains the extracted PDF rather than the outer PalmDB wrapper so a viewer can render it directly.
Implementation
PdfBook parseAzw4Book(final Uint8List bytes, {final String password = ''}) {
final payload = extractAzw4PdfPayload(bytes);
final pdfBook = parsePdfBook(payload.bytes, password: password);
final metadata = pdfBook.metadata.copyWith(
format: BookFormat.azw4,
title: pdfBook.metadata.title ?? payload.title,
);
return PdfBook(
bytes: payload.bytes,
metadata: metadata,
pages: pdfBook.pages,
navigation: pdfBook.navigation,
format: BookFormat.azw4,
pageFiles: pdfBook.files.html,
pageTexts: pdfBook.pageTexts,
extractedImages: pdfBook.files.images,
);
}