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