Skip to main content
Alliosaaa
Inspiring
January 18, 2018
Answered

Unexpected Console Message

  • January 18, 2018
  • 1 reply
  • 780 views

I'm attempting to write a JavaScript for a custom action to create several fields that I often use. I'm first experimenting by using the console window.

I've written the following:

var name      = "KPOR";

var type      = "checkbox";

var page      = 0;

var location  = [78.48, 702.72, 93.6, 689.04];

var KPOR      = this.addField(name, type, page, location);

if (KPOR !== null) {

     KPOR.fillColor = color.white;

     KPOR.strokeColor = color.black;

}

The field was created correctly, however for some reason the console returned "G,0". I would love if someone could explain where that could be coming from.

To that end... is there any sort of index or documentation on the console and interpreting the errors/messages it returns? I don't know where else to turn when something like this happens.

Thank you!

This topic has been closed for replies.
Correct answer Thom Parker

The last line of code in your scripts sets the "color.black", which is the value of executing the line, which is [G,0].  Verify by running the last line by itself.

AFAIK there is no JS error reference, but they are usually self evident.

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 18, 2018

The last line of code in your scripts sets the "color.black", which is the value of executing the line, which is [G,0].  Verify by running the last line by itself.

AFAIK there is no JS error reference, but they are usually self evident.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Alliosaaa
AlliosaaaAuthor
Inspiring
January 18, 2018

Thank you! I ran that line by itself and it returned the same thing. Is there a way to avoid that?

try67
Community Expert
Community Expert
January 18, 2018

There's no reason to, but you can put the code in an anonymous function (it will still return "undefined", ie nothing, though):

(function () {

var name      = "KPOR";

var type      = "checkbox";

var page      = 0;

var location  = [78.48, 702.72, 93.6, 689.04];

var KPOR      = this.addField(name, type, page, location);

if (KPOR !== null) {

    KPOR.fillColor = color.white;

    KPOR.strokeColor = color.black;

}

})();