@dfelix@skumarwudza is trying to create a custom widget placeholder for attachment and want to open custom modal.
We also facing the same issue . Not only for attachment but also have issue with opening existing modal.
Consider below scenario:
As there is signatureWidgetAnnotation to create the signature placeholder and when we click on that signature modal get auto open.
We want same type of widget for Stamp and attachment placeholder and when we click on that we able to open either existing Stamp modal or our own custom modal.
We are stuck at this place please help us on this . Thanks in advance.
@vtiwari Sounds good. But since this is not native, I need to know how are you guys creating it and what type of thing it is so I can tell you how to open a custom modal when clicking it.
Is it a custom annotation? if yes, does it extend some other annotation?
@dfelix It’s SignatureWidget annotation with Image in background. We tried to use ButtonWidgetAnnotation but in this background image does not applying.
Unfortunately, there is no easy and clean way to do this with the current API, but I could achieve the desired behavior with the following code snippet:
Thanks @dfelix . It really worked. Just to add here setTimeout((),timeDuration) , Here timeDuration should be enough to render PDF properly otherwise annotation.innerElement will be undefined. I have used 1000 for safer side as Large size PDF takes time to download from server.
@dfelix Now we are able to open the attachment modal and able to attach the file .
Now we are facing issue that after attach the file when we generate final pdf and open final pdf in Pdf Adob reader but attachment does not open clicking of attachment icon.
Below is the method we are using to generate final PDF:
Load the pdf from local device and create the attachment placeholder on the pdf.
Get the byte array from pdfViewer and upload into our server as file . for eg. sample.pdf
Load the pdf from the server using url and click on attachment placeholder icon and attach a file (for eg. image file)
Export the xfdf using for const xfdf = await annotManager.exportAnnotations({
widgets: false,
links: false,
});
Then we upload xfdf server and our and server used pdftron sdk and merge xfdf into original pdf .
when we download the the final PDF and open it in pdf Adobe reader we are not able to open attachment from final PDF.
While If we download the pdf from webviewer setting menu , adob reader able to detect the attachment and able to open the attached file but it doesn’t work when we generate pdf using merging xfdf with pdf.
@dfelix Again back to this topic . As this solution (adding click listener) on innerElements for when number of pages in pdf is less than 10. When pdf page in increase 20 or 30 then for annotation present in last page (between 15 to 30) click listener failed to add because innerElement is null for those annotation.
we have tried to upgrade pdftron version from 8.3.1 to 8.12.0 but it doesn’t work. Please help us as we are stuck at this place we must have to give the support for for atleast 100 page pdf .