Skip to main content
Known Participant
May 29, 2024
Question

How can I remove field colours when printing a pdf form

  • May 29, 2024
  • 2 replies
  • 1831 views

Hi I have created a form and set the field colours as per our requirements, however, when I print the form the field colours also print. I have found the following code which works great when I print:

 

for(var i=0;i<this.numFields;i++)

this.getField(this.getNthFieldName(i)).fillColor = ["T"];

 

However,  this switches off all field colours for all forms that I open from then on which is not ideal. The problem I have is that I can switch the colour back on, but all fields are one colour, but as you can see in the attached document certain fields need to be certain colours, what is the easiest way to reverse the removal of field colours ensuring that the correct colours end up in the correct fields?

 

Also is there an easier way to set the field colours than what I have done?

 

Any assistance would be greatly appreciated.

 

Cheers

Nicole

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
May 29, 2024

At the event "Document Will Print" save the field object with the color settings in an array. Then change the color of the fields.

At the event "Document Did Print" restore the color of the fields.

Nesa Nurani
Community Expert
Community Expert
May 29, 2024

How does it affect other files, where do you use script?

When you want to print, you can run a script from console, or you can add a script to the file document actions 'Document Will Print'.

Once you're done printing, don't save the file or if you need filled in fields, save before printing under a different name so you also have the original file.

Known Participant
May 29, 2024

I placed in the Document JavaScripts and every other form that I opened up after I printed this one all fields were white instead of having the standard bluish/purple background. I then tried the script in the Document Will Print area of Document Actions and it would not work at all.

try67
Community Expert
Community Expert
May 29, 2024

It can not affect other files. There must have been something else you did.

But the bluish/purplish fill color of the fields you see is a setting of the application to highlight fields on the screen. It does not carry over when the file is printed, so there's no need to disable it.