Best way to add dynamic signature images (canvas / text / upload) to PDF after confirmation? #450
Unanswered
PrettyPuppyCavalier
asked this question in
Q&A
Replies: 0 comments
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 👋
I’m building a signature feature using embed-pdf-viewer and I’d like some guidance on the recommended way to programmatically add signature images to a PDF.
⸻
🔹 Interaction flow (important context)
The signature creation does NOT happen directly on the PDF.
Instead, the flow is:
1. User clicks “Sign” button
2. A modal dialog opens
3. Inside the modal, the user chooses one of three tabs:
• Draw signature (mouse / touch → canvas)
• Text signature (type text, switch between different artistic fonts → canvas)
• Upload image (PNG / JPG)
4. The user previews the result inside the modal
5. Only after clicking “Confirm / Apply”, the signature is added to the PDF
So from the PDF viewer’s perspective, the final input is always:
an image generated at runtime (canvas or uploaded file)
⸻
🔹 What I’m trying to achieve
After the user clicks Confirm, I want to:
• Programmatically insert the generated image into the PDF
• Place it on a specific page (or let the user click to place it)
• Control size and position
• Each insertion may use a different image
This is conceptually similar to an image / stamp annotation, but with dynamic image content.
⸻
🔹 What I’ve tried / investigated
• Annotation tools (addTool)
• Works well for predefined tools
• But defaults.imageSrc appears to be static
• Not suitable when the image changes every time
• setActiveTool(toolId)
• Only toggles tools
• No way to pass runtime data (canvas / base64 image)
• I noticed APIs like:
• createAnnotation
• importAnnotations
These seem like the right direction, but I couldn’t find documentation or examples showing:
• Creating an image/stamp annotation programmatically
• Using a canvas or base64 image as the source
• Setting properties like pageIndex, position, and size
⸻
🔹 Questions
1. Is createAnnotation the recommended approach for adding a signature image after user confirmation?
2. Can a canvas or base64 image be used directly as the image source for a stamp/image annotation?
3. Is there a demo or example showing how to:
• Programmatically create image/stamp annotations
• Import annotations with custom image data
4. If this is not the intended usage, what would be the best practice for implementing a signature workflow like this?
Any guidance, examples, or demos would be greatly appreciated 🙏
Thanks for the great work on this project!
Beta Was this translation helpful? Give feedback.
All reactions