Add PDF support

This commit is contained in:
John Factotum
2023-10-08 21:27:06 +08:00
parent bcfb942935
commit a63a68eda0
6 changed files with 76736 additions and 2 deletions
+13 -1
View File
@@ -8,6 +8,13 @@ const isZip = async file => {
return arr[0] === 0x50 && arr[1] === 0x4b && arr[2] === 0x03 && arr[3] === 0x04
}
const isPDF = async file => {
const arr = new Uint8Array(await file.slice(0, 5).arrayBuffer())
return arr[0] === 0x25
&& arr[1] === 0x50 && arr[2] === 0x44 && arr[3] === 0x46
&& arr[4] === 0x2d
}
const makeZipLoader = async file => {
const { configure, ZipReader, BlobReader, TextWriter, BlobWriter } =
await import('./vendor/zip.js')
@@ -79,7 +86,12 @@ const getView = async file => {
const { EPUB } = await import('./epub.js')
book = await new EPUB(loader).init()
}
} else {
}
else if (await isPDF(file)) {
const { makePDF } = await import('./pdf.js')
book = await makePDF(file)
}
else {
const { isMOBI, MOBI } = await import('./mobi.js')
if (await isMOBI(file)) {
const fflate = await import('./vendor/fflate.js')