pdfjs icon indicating copy to clipboard operation
pdfjs copied to clipboard

error creating new external PDF document with base64 PDF

Open ex-git opened this issue 4 years ago • 1 comments

const dataUrl = 'data:application/octet-binary;base64,' + url; const blob = await fetch(dataUrl) .then((res) => res.blob()); const ext = new pdf.ExternalDocument(blob.arrayBuffer());

got error Name must start with a leading slash, found: %

const dataUrl = 'data:application/octet-binary;base64,' + url; const blob = await fetch(dataUrl) .then((res) => res.blob()); const file = new Blob( [blob], { type: 'application/pdf' }, ); const fileURL = URL.createObjectURL(blob); const res = await fetch(fileURL).then((data) => data.blob()); const ext = new pdf.ExternalDocument(res.arrayBuffer());

same error.

ex-git avatar Jun 23 '20 17:06 ex-git

Hi, this error is most probably related to a syntax error in the PDF your are trying to add, see https://github.com/rkusa/pdfjs/issues/218. Your code looked good form a quick glance, so I'd almost expect that it should work with most PDFs.

rkusa avatar Jun 30 '20 14:06 rkusa