Replies: 2 comments 8 replies
-
Before answering your question, allow me a side remark: if you're using the async addTextField() {
try {
const existingPdfBytes = await this.getPdfBytesFromStaticFile(this.pdfSrc);
const doc = await PDFDocument.load(existingPdfBytes);
const page = doc.getPages()[0];
const nameField = doc.getForm().createTextField('nameField');
nameField.setText('Enter your name');
nameField.addToPage(page, { x: 50, y: 700, width: 200, height: 20 });
const modifiedPdfBytes = await doc.save();
const bytes = new Uint8Array(modifiedPdfBytes);
this.pdfSrc = new Blob([bytes], { type: 'application/pdf' });
console.log("success");
} catch (error) {
console.error('Failed to get PDF bytes:', error);
}
} Granted, in this particular case, your promises almost read like linear code, but in general, newbies (and me) have a hard time wrapping their head around the callbacks. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Beta Was this translation helpful? Give feedback.
7 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Is it possible to add PDF-lib's form fields in annotationLayer as I want to move & resize these fields in the pdf?
This is currently what I've started, moving forward I want the textfield to move in the annotationLayer of the pdf-viewer. Thanks
Beta Was this translation helpful? Give feedback.
All reactions