You are viewing limited content. For full access, please sign in.

Question

Question

"Print" to .pdf via button on form

asked on November 13, 2015

Hi all,

 

I am trying to figure out a way to save the form as a .pdf file to a specified location when the user hits a button on the form.  

I would like to do this outside of a workflow if possible. 

Can someone please help me out with this?

 

Thanks in advance,

Dane

0 0

Replies

replied on November 13, 2015

Hello Dane,

Where exactly do you want to save the Form? If you mean that you wish to save it to a repository location, this can be accomplished in the Forms Process Modeller using a "Save to Repository" service task. If you'd like this to be the behavior for all forms in a process, you can configure this in the Publish tab.

Hope this helps!

0 0
replied on November 16, 2015

Hi James,

 

Thank you for your suggestion. I would like to save to the repository but without using the process modeler.  I am troubleshooting an issue I am coming across which prevents the form from entering the process at all.

0 0
replied on November 16, 2015

If I'm understanding you correctly, sounds like you will have to use the SDK to save the form to the repository as well as use wkhtmltopdf to get the form to a pdf first. This isn't easily done due to authentication issues with asp.net. Seems like a lot of work for little gain. Unless you must absolutely go this route, I would use the process modeler.

0 0
replied on November 16, 2015

As what Chris said, using the process modeler to save a form as a .pdf into the repository is the best way to go at it. However it seems you are encountering some issue that is preventing the form from entering that "Save to Repository" task? Would you be able to elaborate on the issue you're seeing? Perhaps we can see what may be holding up your process.

0 0
replied on November 17, 2015

Yes, it will not allow me to save to the repository through the "Save to Repository" task when I have javascript in place that allows me to sign in the signature field with a Topaz signature pad.  I can get up until the point where it says "Thank You! Your form has been submitted" However, when I try to send an email or download the form from the thank you page, I get these errors: 

Unable to send an email. Please contact your system administrator. 

Exit with code 1 due to network error: ConnectionRefusedError

 

 

0 0
replied on November 17, 2015

Ah, I see, so the issue only occurs when you incorporate your javascript into your process, is that correct? So if you were to not use any javascript, or create a new simple Forms process, that will allow you to save into the repository? I am just wishing to narrow down and clarify if the issue would be with Forms itself or with the javascript involved.

0 0
replied on November 17, 2015

The problem only occurs when the javascript is in place.  Otherwise everything works properly. 

0 0
replied on November 17, 2015 Show version history

Ahhh... this sounds like a wkhtmltopdf issue. If you go to the server application logs in Event Viewer you should see something similar to 

This is due to the wkhtmltopdf process not able to load the javascript. One way to get around this is to detect if the form has been submitted and if so, skip the loading of the offending javascript file. You can detect if the form has been submitted by using one of the following functions:

function formSubmitted() {
     return $('li[attr=[your field name here]]').find('div.cf-medium').length>0 || $('li[attr=your field name here]').find('input.singleline').length>0;
}

or 

function formSubmitted() {
    return !LF.LFForms;
}

 

0 0
replied on November 17, 2015

Thanks for your suggestion Chris.  Can you please explain what you mean by "skip the loading of the sigweb.js file?" 

 

0 0
replied on November 17, 2015

Thanks Chris,


After testing it turns out that the loading of the sigweb.js file is preventing the form from being submitted.  Any tips on how to work around this? Without the file the signature pad does not work with the form. 

0 0
replied on November 17, 2015

If you are loading your "sigweb.js" file using the jQuery.getScript(); function, you could use the function in my previous reply to do something like:

$(document).ready(function() {
   if (!formSubmitted()) $.getScript('[url]/sigweb.js', initSigweb);
});

 

0 0
replied on November 17, 2015

Thank you for your suggestion. With that code in place, I am still having the same issue.

0 0
replied on November 17, 2015

Could you post your code?

0 0
replied on November 17, 2015 Show version history

Here is the code: 

 

​
var baseUri = "http://localhost:47289/SigWeb/";

function initSigWeb(){
        var ctx = $("#sigTabContent .signatureSettings").getContext('2d');
          ResetParameters();
        SigWebSetDisplayTarget(ctx);
        tmr = setInterval(SigWebRefresh, 50);
        SetDisplayXSize(438);
        SetDisplayYSize(150);
    SetJustifyMode(0);
        SetTabletState(1);
        $("#form-signature-dlg").on("shown.bs.modal", function(){
              $("#sigNav a:eq(1)").click();
                KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              SetLCDCaptureMode(2);
              $("button.signSignatureBtn").removeAttr("disabled");
        });
          $("span.clearSignature").on("click", function(){
              SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              $("button.signSignatureBtn").removeAttr("disabled");
              setTimeout(function(){SetLCDCaptureMode(2);}, 2000);
          });
          $("#form-signature-dlg").on("hidden.bs.modal", function(){
            SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
    });
}

$(document).ready(function(){
  $.getScript("http://localhost:47289/SigWeb/SigGetScript/SigWeb.js", initSigWeb);
});

$(document).ready(function() {
   if (!formSubmitted()) $.getScript('http://localhost:47289/SigWeb/SigGetScript/sigweb.js', initSigweb);
});
0 0
replied on November 17, 2015

Try this:

var baseUri = "http://localhost:47289/SigWeb/";

function formSubmitted() {
   return !LF.LFForms;
}

function initSigWeb(){
        var ctx = $("#sigTabContent .signatureSettings").getContext('2d');
          ResetParameters();
        SigWebSetDisplayTarget(ctx);
        tmr = setInterval(SigWebRefresh, 50);
        SetDisplayXSize(438);
        SetDisplayYSize(150);
    SetJustifyMode(0);
        SetTabletState(1);
        $("#form-signature-dlg").on("shown.bs.modal", function(){
              $("#sigNav a:eq(1)").click();
                KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              SetLCDCaptureMode(2);
              $("button.signSignatureBtn").removeAttr("disabled");
        });
          $("span.clearSignature").on("click", function(){
              SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              $("button.signSignatureBtn").removeAttr("disabled");
              setTimeout(function(){SetLCDCaptureMode(2);}, 2000);
          });
          $("#form-signature-dlg").on("hidden.bs.modal", function(){
            SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
    });
}

$(document).ready(function() {
   if (!formSubmitted()) $.getScript('http://localhost:47289/SigWeb/SigGetScript/sigweb.js', initSigweb);
});

 

0 0
replied on November 18, 2015

Thank you for your suggestion. Unfortunately the signature pad does not work with this code.  It does not show in the signature box on the form.

0 0
replied on November 18, 2015

One last thing to try. Change the url from "http://localhost:47289/SigWeb/sigweb.js" to "http://[ip address of machine]:47289/SigWeb/sigweb.js". Make sure to put the ip address assigned by dhcp and not the loopback address (127.0.0.1). Below is the revised code:

function initSigWeb(){
        var ctx = $("#sigTabContent .signatureSettings").getContext('2d');
          ResetParameters();
        SigWebSetDisplayTarget(ctx);
        tmr = setInterval(SigWebRefresh, 50);
        SetDisplayXSize(438);
        SetDisplayYSize(150);
    SetJustifyMode(0);
        SetTabletState(1);
        $("#form-signature-dlg").on("shown.bs.modal", function(){
              $("#sigNav a:eq(1)").click();
                KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              SetLCDCaptureMode(2);
              $("button.signSignatureBtn").removeAttr("disabled");
        });
          $("span.clearSignature").on("click", function(){
              SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
              $("button.signSignatureBtn").removeAttr("disabled");
              setTimeout(function(){SetLCDCaptureMode(2);}, 2000);
          });
          $("#form-signature-dlg").on("hidden.bs.modal", function(){
            SetLCDCaptureMode(1);
              KeyPadClearHotSpotList();
                ClearSigWindow(1);
               ClearTablet();
    });
}

$(document).ready(function() {
 $.getScript('http://[192.168.0.44]:47289/SigWeb/SigGetScript/sigweb.js', initSigweb);
});

Just a shot in the dark, but it may work. Wkhtmltopdf is very finicky.

0 0
replied on November 19, 2015

Unfortunately no luck with that code either.  Thanks for your help and I will post on here if I figure it out.

0 0
replied on November 20, 2015
1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.