Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

PrePrint

Avatar

Level 4

How would I script a prePrint event if I don't want a subform to print if the fields inside it are empty?

4 Replies

Avatar

Level 10

Hi,

to prevent user from printing you can use the validate element in the config DOM.

Here's an article which descibes how to use it.

http://forms.stefcameron.com/2008/04/13/prevent-printing-pdf-forms-in-acrobat-8/

Avatar

Level 4

I don't want to restrict printing by the user unless the fields are filled, I want the subforms that have unfilled fields to not print on the document. I probably didn't explain it well.

Let me try again.... I have a form with a visible subform with fill in fields and there is a checkbox in front of the first field. If that checkbox isn't checked and the fields are empty, I don't want that subform to print. Does that make sense?

Avatar

Level 10

Hi,

I use a function like the one below to test for a subform containing empty fields, so you could pass in the subform and if you get a true response set the presence property of the subform to "hidden".

function isNull(node)

{

    //Debug.trace(arguments);

    var result = true;

    switch (node.className)

    {

        case "exclGroup":

        case "field":

            result = node.isNull;

            break;

    }

    for (var i=0; i<node.nodes.length && result; i++)

    {

        var childNode = node.nodes.item(i);

        if (childNode.isContainer && childNode.className !== "draw" && childNode.className !== "variables")

        {

            result = isNull(childNode);

        }

    }

    return result

}

Depending on how complicated your subform is it might just be simplier to test the fields individually.

Bruce

Avatar

Level 3

Now, if I could get someone to take my form and show me how to do one of the subforms on it, this would be awesome!  LOL