Invalid xref stream index [with codesandbox]
manuschillerdev opened this issue · 2 comments
Hi, thanks for your great work with this library.
I have a pdf with can be filled without problems on the official demo page.
If I load it via fetch
, and convert it to an Array Buffer via resonse.arrayBuffer()
I get the following exception:
Uncaught (in promise) Error: Invalid xref stream index: index says 1 objects, but space for 12
I created a csb to demonstrate my Problem:
https://codesandbox.io/s/youthful-swanson-jm9pm
import React, { useEffect } from "react";
import ReactDOM from "react-dom";
const pdf = require("./pdfform.minipdf.dist");
function App() {
useEffect(() => {
// both form.pdf and beratungsprotokoll.pdf are working
// with the official demo at:
// https://phihag.github.io/pdfform.js/docs/demo.html
// loaded via fetch() however both produce
// an xref error:
// Invalid xref stream index: index says 1 objects, but space for 12
fetch("https://jm9pm.csb.app/beratungsprotokoll.pdf")
.then(res => res.arrayBuffer())
.then(pdfArrayBuffer => {
console.log(pdfArrayBuffer);
console.log(pdf());
console.log(pdf().list_fields(pdfArrayBuffer));
});
}, []);
return <div>see console for status</div>;
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
FYI: The error is not visible in the built-in console in codesandbox
. It only pops up in the browser devtools console 👍
P.S.: Hi Manu, great seeing you again!
I followed the installation instructions at https://github.com/phihag/pdfform.js#installation and used the version at https://raw.githubusercontent.com/phihag/pdfform.js/dist/dist/pdfform.minipdf.dist.js for testing purposes.
Using the currently published npm version 1.0.14 everything works fine:
https://codesandbox.io/s/boring-violet-n3v6u
@phihag I will glady do a PR for updating the readme / installation section if you want?
@marvinhagemeister always good to see you ❤️😄