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

Question

Question

Suppress the rendering of a given HTML element on the PDF that results when a form is submitted?

asked on April 3, 2017 Show version history

Question: how to supress the rendering of a given HTML element on the PDF that results when a form is submitted?

Scenerio: we have a form that has 2 checkboxes on it - these checkboxes make certain pages on a form visible / not visible.
Form has 3 pages, all need to be rendered together in a single PDF.
However, when the form is submitted, these checkboxes are not relevant to what the client needs and we want to suppress them.

Attempt 1
checkbox 1 no CSS
checkbox 2 no CSS

submit button hides both via javascript
        $("#q6").hide();
        $("#q7").hide();

result: checkboxes both still render on PDF

Attempt 2
checkbox 1 has 'hidden' CSS class
checkbox 2 has 'hidden' CSS class

form "ready" javascript
    $('#q6').removeClass('hidden');
    $('#q7').removeClass('hidden');

form "submit" request
 $(".action-btn").click(function(){
        $("#q6").hide();
        $("#q7").hide();    
 };

Result: checkboxes both still render on PDF

Attempt 3
checkbox 1 has 'hidden' CSS class
checkbox 2 has 'hidden' CSS class

no other CSS / javascript

Result: checkboxes don't render on PDF

but Attempt 3 is not doing what is needed - it was done just to see if ANYTHING would suppress the checkboxes.

So, how does the PDF rendering engine work upon submittal - and what, if anything, can we do to suppress rendering of a given html element on the resulting PDF in the repository?

0 0

Replies

replied on April 10, 2017

Hi Mark,

On the submitted form (or the printed PDF), your click events are not triggered so the attempt 1&2 have no effect.

One solution is to check if the form is read-only or not in the document ready script, and if form is read-only, set the fields hidden by default.

The script is like this:

$(document).ready(function(){
  if ($("input[name=IsLocked]").val() == "True") {
    $("#q6").hide();
  }
})

 

1 0
replied on November 2, 2021

I've been chasing the same problem for a while, and happy to find this simple solution. It works beautifully when we want to filter off a form field for Save to Repository task. Thank you, Rui.

0 0
replied on April 3, 2017

Shorter version: how to "fool" wkhtmltopdf into not rendering a given control.

0 0
replied on April 7, 2017

Following up on my own post to help others:

No real way to "fool" the engine, but the workaround was as follows:

 - set all UI elements to have HIDDEN css class, such that those UI elements will not render on the PDF

- have another button / text link with unobtrusive text, when clicked, removes the HIDE css class from those elements.  Users will just have to be trained on that course of action, if they do NOT want those UI elements on the resulting PDFs

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.