Skip to main content
Participant
April 30, 2020
Answered

Cannot make my own class

  • April 30, 2020
  • 2 replies
  • 1376 views

I am trying to mkae my own class in Adobe Acrobat DC using Javascript, but I keep getting this error 

"Syntax Error: class is a reserved identifier".  Which doesnt make any sense as I am not making a variable called "class" I am defining a class to make objects.

 

Here is my code:

 

If anyone can help, please get back ASAP as this is a project for a client and I have a certain number of hours to work on it and get it done.

 

Thanks

 

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

You got it. Need to do it the old fashion. Construtor class and then prototypes. But the end result is exactly the same thing.  Keep in mind that JavaScript is not true OOP, no polymorhpism, no inheritence, etc. Just simple objects.

 

2 replies

Thom Parker
Community Expert
Community Expert
April 30, 2020

There are no true classes in JavaScript, the "class" defintition is just a shortcut for creating regular javascript objects. The core JS model in the current version of Acrobat doesn't include it.  

But there is nothing stopping you from just creating regular JS objects.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 30, 2020

So what you are saying is that Acrobats JS model doesnt include making JS objects using ES6 classes (like how I am doing right now?). So I would need to start off by making a contructor functions (example for me it would look like fucntion LinkedList() { ...WHatever needed to construct ... } ) then use prototypes for my methods to my object?

 

Sorry if these are quite simple questions, I have worked with classes & objects in JS before but never contstructed them, and I recently did alot of OOP in C++, so the ES6 method made the most sense to me. 

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 30, 2020

You got it. Need to do it the old fashion. Construtor class and then prototypes. But the end result is exactly the same thing.  Keep in mind that JavaScript is not true OOP, no polymorhpism, no inheritence, etc. Just simple objects.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
April 30, 2020

May be that this is not possible in Adobe Acrobat.

Participant
April 30, 2020

So there is no way to make my own Classes or Objects in Adobe Acrobat?

Thom Parker
Community Expert
Community Expert
April 30, 2020

Of course you can create your own object definitions.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often