mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:23:45 -05:00
27 lines
693 B
JavaScript
27 lines
693 B
JavaScript
const fs = require('fs')
|
|
const { FSPdfManager } = require('./FSPdfManager')
|
|
|
|
async function parseXrefTable(path, size, checkDeadline) {
|
|
if (size === 0) {
|
|
return []
|
|
}
|
|
|
|
const file = await fs.promises.open(path)
|
|
try {
|
|
const manager = new FSPdfManager(0, { fh: file, size, checkDeadline })
|
|
|
|
await manager.ensureDoc('checkHeader')
|
|
checkDeadline('pdfjs: after checkHeader')
|
|
await manager.ensureDoc('parseStartXRef')
|
|
checkDeadline('pdfjs: after parseStartXRef')
|
|
await manager.ensureDoc('parse')
|
|
checkDeadline('pdfjs: after parse')
|
|
return manager.pdfDocument.catalog.xref.entries
|
|
} finally {
|
|
file.close()
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
parseXrefTable,
|
|
}
|