Skip to main content
Alliosaaa
Inspiring
Jan 18, 2018 8:27 PM UTC
Answered

Unexpected Console Message

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 is closed to new replies. Start a new post to keep the conversation going.
Thom Parker
Thom ParkerCorrect answer
Community Expert
Jan 18, 2018 8:33 PM UTC

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

6 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Jan 18, 2018 8:33 PM UTC

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.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Alliosaaa
AlliosaaaAuthor
Inspiring
Jan 18, 2018 8:41 PM UTC

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

Translate
try67
Community Expert
Community Expert
Jan 18, 2018 8:58 PM UTC

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;

}

})();

Translate