Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.74k stars 645 forks source link

Failed to parse PDF document #1491

Open haohaodushu opened 1 year ago

haohaodushu commented 1 year ago

What were you trying to do?

Check that the pdf is normal.It proved to download and preview normally

How did you attempt to do it?

Only one pdf will have this situation, and the other pdf resources will work properly

What actually happened?

` const source = await rpn.get({ uri: uri, encoding: null })

console.log(source.length); //  127488

await PDFDocument.load(source)

Error: Failed to parse PDF document (line:247 col:15 offset=127488): Expected next byte to be 62 but it was actually undefined`

What did you expect to happen?

PDFDocument can load pdf

How can we reproduce the issue?

const source = await rpn.get({ uri: uri, encoding: null })

console.log(source.length); //  127488

await PDFDocument.load(source)

Version

1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

No response

haohaodushu commented 1 year ago

0000124234 00000 n 0000124984 00000 n 0000125064 00000 n 0000126159 00000 n 0000126385 00000 n trailer << /Size 20 /Root 19 0 R /Info 18 0 R /ID [<37E8BDF7F171B1EE9E62F80CC8CA0109><37E8BDF7F171B1EE9E62F80CC8CA0109>]

startxref 126529 %%EOF 00010 00000 n 0000007332 00000 n 0000012687 00000 n 0000066928 00000 n 0000125951 00000 n 0000014848 00000 n 0000015165 00000 n 0000064293 00000 n 0000064553 00000 n 0000065531 00000 n 0000065611 00000 n 0000067071 00000 n 0000123972 00000 n 0000124234 00000 n 0000124984 00000 n 0000125064 00000 n 0000126159 00000 n 0000126385 00000 n trailer << /Size 20 /Root 19 0 R

Found other information after the trailer %%EOF