Skip to content

Invalid xref stream index [with codesandbox] #29

@manuschillerdev

Description

@manuschillerdev

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions