Creating a signature field in a PDF using JavaScript

146 views
Skip to first unread message

Julio Cesar Llavilla Ccama

unread,
Apr 6, 2021, 11:45:25 AM4/6/21
to PDFTron WebViewer
I want to create a field in which a signature can be inserted something like what is indicated in the documentation:
https://www.pdftron.com/documentation/web/guides/interacting-with-signature-field/
default-sign-here.png
   <script>
    WebViewer({
      path: 'lib/',
      fullAPI: true,
      initialDoc: 'example0006.pdf',
      //config: 'config.js',
    }, document.getElementById('viewer')).then(async instance => {
      const { Annotations, annotManager, PDFNet, CoreControls, signatureWidgetAnnots, docViewer  } = instance;

      const createSignHereElement = Annotations.SignatureWidgetAnnotation.prototype.createSignHereElement;
      Annotations.SignatureWidgetAnnotation.prototype.createSignHereElement = function() {
        const signHereElement = createSignHereElement.apply(this, arguments);
        signHereElement.style.background = 'red';
        return signHereElement;
      }

    });
  </script>

I have tried everything and it has not worked for me, please if anyone knows how it works I will appreciate it very much.

Regards


jlin

unread,
Apr 6, 2021, 3:47:02 PM4/6/21
to PDFTron WebViewer
Hi there, 

Thanks for reaching out!

If you would like to add a signature field to a PDF directly in the web browser, you can take a look at this sample: https://www.pdftron.com/samples/web/samples/forms/form-builder/#
The sample code is available in the `WebViewer/samples/forms/form-builder` if you download the WebViewer folder and also available online: https://www.pdftron.com/documentation/samples/js/form-builder/

Best Regards, 
Jimmy Lin
Software Developer
PDFTron Systems, Inc.

CONFIDENTIALITY NOTICE: This message (and any attachment to it) is intended only for the use of the individual or entity to which it is addressed in the header, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Any reproduction, distribution, modification or use of the contents of this message (and any attachment to it) by any individual or entity other than the intended recipient is prohibited. If you have received this communication in error, please notify us immediately and delete the original.
Reply all
Reply to author
Forward
0 new messages