mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add PDF support
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user