Expand my Community achievements bar.

SOLVED

Turning off borders on form fields for printing

Avatar

Level 2

Is it possible to turn off the borders (or set the color to "none") on form fields when printing a form?  I'd rather the only the data, but not the border boxes, print.

I did have a look at the XML source and I suspect it's possible, but I'm a LC newbie.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

No problem! I just going through a couple of things (you might already have these sorted, so please forgive me, but just in case).

You don't need to go near the XML Source that often (if at all). Sometimes it is handy if you want to change multiple occurrences of a string (with find and replace).

Firstly set up your workspace, something like below.

07-05-2009 19-06-54.png

You will need to have the panels open (Layout, Object, Border, Font, Paragraph,Hierarchy, Script Editor, etc.).

I have set up a field "recipientName" and inserted the prePrint script. Note the drop down list of events that you can choose from. Also note that you can select between two languages Javascript and Formcalc.

07-05-2009 19-17-40.png

This is the Script Editor, it is a very important interface, where you can insert script for your form objects. You can access it from the Window menu (or clicking Control + Shift + F5). When you have it open, drag the bottom bar to make it a decent size for viewing and editing script.

The same approach is used to put the "visible" script in the postPrint event.

All of this is done from within the main LC design view, without touching XML source itself. What you are trying to achieve here requires access to deep level properties of the object. For "normal" scripting for an object, you would not need the fully resolved name.For example:

recipientName.rawValue = "Niall";

I would recommend that you consider carefully where you place script (in which event), The help file, forums, and books talk about this at length.

07-05-2009 19-28-30.png

One last point, when you are developing your form (like this one which has dynamic content), then you must save your file as Dynamic PDF. You can set this in the Form Properties / Defaults dialogue (from the File menu). Otherwise the dynamic content will not fire.

For what is is worth, I will upload the PDF with the single object in it. It may take a bit of time to get through. If you use this technique, please remember that the UI properties of different objects are accessed using different edits. Check out the help file:

07-05-2009 19-38-16.png

Hope this helps,

Niall

View solution in original post

5 Replies

Avatar

Level 2

Well, I've been playing a bit.  I tried adding some JavaScript code to the printer event:

<event name="event__click" activity="click">
                <script contentType="application/x-javascript">
                Recipient.borderWidth = "0in";
                xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);
                </script>
</event>

Recipient is a text field with a border, but this made no difference in the printing. In other words, the border still prints even though I explicitly reset the borderWidth to 0. I suspect that the xfa.host.print just goes back to the original field for its input.


However, I *can* do what I want if I duplicate the Field object and make the first one relevant="-print" and the second one relevant="-screen", reorder the tabbing and set the border width to zero on the second instance.

I then get a nice border around the text field on the screen and no border around the text field on the printed version. This is, off course, a total kludge and I'm thinking there must be another way...  although I suppose I could automate this with scripting?

Moving quickly from newbie to dangerous...

Avatar

Level 10

Well "dangerous",

There is nothing wrong with a bit of healthy disrespect for the "scripting" rules.

I am not sure how backward complaint this is, but here goes...

In the pre-print event of textfields you could have the following Javascript:

     xfa.resolveNode("form1.page2a.scaffoldBoard.ui.textEdit.border.edge").presence = "invisible";

This is matched by a corresponding script in the post-print event:

     xfa.resolveNode("form1.page2a.scaffoldBoard.ui.textEdit.border.edge").presence = "visible";

Don't know what it is going to do for performance if you have a lot of fields to turn on and off with the print command. Also please note that "textEdit" covers textfields only. Replace this with numericEdit for numericfields, etc...

I would put this script in every object. I suspect that a routine could be scripted to look at each object type in turn and change the presence property. But this is beyond me.

Hope you move back to the "safe" zone soon ;-)

Niall

Avatar

Level 2

Thanks for the help, Niall, but since I'm a noob, I still can't figure it out.  I tried inserting the following code into various places in my XML file (I get no errors, but it doesn't do anything...)

<event name="prePrint">
     <script contentType="application/x-javascript">
          xfa.resolveNode("topmostSubform.Page2.Recipient.ui.textEdit.border.edge").presence = "invisible";
     </script>
</event>
<event name="postPrint">
     <script contentType="application/x-javascript">
          xfa.resolveNode("topmostSubform.Page2.Recipient.ui.textEdit.border.edge").presence = "visible";
     </script>
</event>

I tried inserting it into the "print button" code before the actual print call.  I tried inserting it into the textEdit block within "Recipient", but here I should be able to use "this.border.edge" instead of the long version, so I think that's not where the code goes?

I've spent a day guessing and playing because I don't want to waste someone else's time,  but the Scripting Reference doc gives no examples of actually using the pre or postPrint event.

Thanks in advance for any further advice.

Avatar

Correct answer by
Level 10

Hi,

No problem! I just going through a couple of things (you might already have these sorted, so please forgive me, but just in case).

You don't need to go near the XML Source that often (if at all). Sometimes it is handy if you want to change multiple occurrences of a string (with find and replace).

Firstly set up your workspace, something like below.

07-05-2009 19-06-54.png

You will need to have the panels open (Layout, Object, Border, Font, Paragraph,Hierarchy, Script Editor, etc.).

I have set up a field "recipientName" and inserted the prePrint script. Note the drop down list of events that you can choose from. Also note that you can select between two languages Javascript and Formcalc.

07-05-2009 19-17-40.png

This is the Script Editor, it is a very important interface, where you can insert script for your form objects. You can access it from the Window menu (or clicking Control + Shift + F5). When you have it open, drag the bottom bar to make it a decent size for viewing and editing script.

The same approach is used to put the "visible" script in the postPrint event.

All of this is done from within the main LC design view, without touching XML source itself. What you are trying to achieve here requires access to deep level properties of the object. For "normal" scripting for an object, you would not need the fully resolved name.For example:

recipientName.rawValue = "Niall";

I would recommend that you consider carefully where you place script (in which event), The help file, forums, and books talk about this at length.

07-05-2009 19-28-30.png

One last point, when you are developing your form (like this one which has dynamic content), then you must save your file as Dynamic PDF. You can set this in the Form Properties / Defaults dialogue (from the File menu). Otherwise the dynamic content will not fire.

For what is is worth, I will upload the PDF with the single object in it. It may take a bit of time to get through. If you use this technique, please remember that the UI properties of different objects are accessed using different edits. Check out the help file:

07-05-2009 19-38-16.png

Hope this helps,

Niall

Avatar

Level 2

Thanks for all the help, Niall.  It's much appreciated.  (And, yeah, I think I understand now.)

Tad