Replies: 1 comment 1 reply
-
bumping this |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, Javascript/HTML newbie here.
I have a PDF file with editable fields that I can load into an iframe using the PDFLib.PDFDocument.load and getElementByID javascript commands as shown here:
const url = './MyPDF.pdf'
const existingPdfBytes = await fetch(url).then(res => res.arrayBuffer())
const pdfDoc = await PDFLib.PDFDocument.load(existingPdfBytes)
const pdfDataUri = await pdfDoc.saveAsBase64({ dataUri: true });
document.getElementById('pdf').src = pdfDataUri;
I can then edit the fields in this iframe/PDF in my browser, but I don't know how to read back this updated PDF.
If I use the getFields() command on pdfDoc, I just get back my original data, not what I manually updated.
Is there a way to get this manually updated data?
Note that I tried using the contentWindow command to read the contents of the iframe and then turn that into a pdfdoc via the load command, but that didn't work. It fails with a 'No PDF header found' error. I guess frameContent is not an object that can be used
by load().
var frameObj = document.getElementById('pdf');
var frameContent = frameObj.contentWindow.document.body.innerHTML;
const pdfDoc2 = await PDFLib.PDFDocument.load(frameContent)
Thanks,
John
Beta Was this translation helpful? Give feedback.
All reactions