Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trouble running VS Code to edit scripts

Community Beginner ,
May 26, 2024 May 26, 2024

I feel like SUCH a scrub but I've never worked in Acrobat before. I downloaded all the extensions I need (I think) but when I add a JS action in my form and hit edit, I get an error in VS code saying the file path doesn't exist. 

I feel like I must be doing something out of order. 

TOPICS
Acrobat SDK and JavaScript , Mac
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2024 May 26, 2024

What script do you use?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

By VS? do you mean Microsoft Visual Studio? VS has nothing to do with Acrobat scripting. So how exactly are you using it?

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 28, 2024 May 28, 2024

First of all, big fan, thom. 

And no, VS Code not Visual Studio. I read in multiple places that since Adobe stopped supported Extendscript the default way to make scripts not in the app is VS Code. 

I worked it out though. I didn't realize you could call functions in the /CONTENTS/ JavaScript folder from the document. So I'm writing my scripts in VS Code and running them from the document. Just have a few functions I can't GE working quite right but I'm getting there. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

There are several ways to automate Acrobat.  So it is important for you to be explicit so we know what you are talking about, so we know.

 

You mention "not in the app" so I'm assuming you mean to control Acrobat from an external source. In this case you would need to use the IAC, which is an Window's OLE (or Active X) module.   

Here's the reference for the IAC

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/interapp/index.html

 

The IAC can be access from many different programming environments. The most common, and easiest is VB and VBA.  Although it can also be used from C++, C# (and other .Net environs), and possible even ExtendScript, or JavaScript run from the Powershell. But I have not need anything about using the IAC from ExtendScript. 

 

VS Code is not a programming language, but rather a cutdown version of Visual Studio, that is intened for scripting purposes, rather than hard core programming.  I imagine you are using it write ExtendScript to access the IAC?.  From what I've seen this is used for automating  the other Adobe applications, not Acrobat. 

 

But then you said that you used VSCode to add a JS action to a form. So are you using VSCode as the JS editor in Acrobat. This idea is contrary to your first statement about using ExtendScript for externally controling Acrobat. Please be complete and clear in your explanation, so we can provide reasonable help. 

 

 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 28, 2024 May 28, 2024
I’m not trying to control Acrobat or automate anything. I’m making a
dynamically editable form. My client wants an invoice he can add line items
to, ad descriptions, etc. so on his end he will be able to hit a button and
add a text field. So I’m just editing the js these buttons call as
actions.

--
This email and any files transmitted with it may contain information that
is PRIVILEGED AND CONFIDENTIAL. It is the property of Acadian Companies and
is intended only for the use of the intended recipient. If you have
received this email in error, do not disseminate, distribute, forward,
print or copy this email or any of its attachments. Immediately
destroy/purge the email and all attachments and notify the sender by reply
of email. Any misuse/abuse may result in disciplinary action and/or legal
liability. Unauthorized interception of this email is a violation of
federal law.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

Excellent, that is the information we need. You want a form that can automatically add pages. 

The PDF/scripting feature you need is called Page Templates.  Page templates are regular pages that are setup to be repeatable.  They are created from the "Organize Pages" tools, on the "More" menu.

 

PageTemplateCreation.jpgexpand image

 

Search for it on this forum and you'll find plenty of info. 

 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 28, 2024 May 28, 2024

Okay so like I said I'm actually a fan of your videos...but the condescension really isn't necessary.  Especially when you're not reading very carefully. I did not say he wants to add pages. He wants to add fields. As in sometimes his invoice will have two line items and sometimes they will have 5. More importantly, there's a 'description' field underneath the line item. Sometimes a line item will have two description sub fields and sometimes it won't have any. And where the fields sit on the page will depend on all these variables. If line item 1 has two descriptions then line item 2 will be further down than if it had none. 

I am making a form that allows my client to enter his first line item, hit a button if he wants to add a description. The JS will make a field in the appropriate spot. If he he doesn't have a description, he'll hit a different button and the JS will place his next line item, again, in the right spot. 

like I said, I've got it mostly worked out. At least the part I was wondering about when I made this post. 

thanks for take the time and responding, truly. You just didn't have to be inpatient and condescending.  At least if you're goal actually is to help people learn

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024

I apologize for the offense. However, it is very frustrating working with incorrect and partial information. The VSCode discussion for example. My intention is to get clear and complete info. And now we have some of it.

 

To that end, Page templates are also a solution, and a much easier one to implement than adding individual form fields.  Because, adding a new section to a form is more than just adding form fields, it's also the text labels that go with the fields. But adding fields individually works as well.

 

Now, about the original post. You would be much better served to use NotePad++ as your code editor for JavaScript. It opens quickly, so it is also a good choice to use as the default Acrobat JavaScript editor.

However, if you want to use VSCode, you'll need to explain more about the issue you are having. 

 

  

 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 28, 2024 May 28, 2024
Lol you’re not reading carefully. I already solved my problem and edit in
VS Code and just save to the Javascripts folder. And I know it’s more than
just adding a field. But luckily I’ve got the documentation and it’s got
all the stuff I need and can look it up.

*PS- “Notepad ++ is better than VS Code” is definitely a take I haven’t
heard very often lol. *

--
This email and any files transmitted with it may contain information that
is PRIVILEGED AND CONFIDENTIAL. It is the property of Acadian Companies and
is intended only for the use of the intended recipient. If you have
received this email in error, do not disseminate, distribute, forward,
print or copy this email or any of its attachments. Immediately
destroy/purge the email and all attachments and notify the sender by reply
of email. Any misuse/abuse may result in disciplinary action and/or legal
liability. Unauthorized interception of this email is a violation of
federal law.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2024 May 28, 2024
LATEST

Part of the confusion is the mention of using a folder level script.  Folder level scripts are used for Automation. Since you are not automating, or using scripts that require priviledge, then there is no need to use a folder level script. Everything can be placed in a document script.  This will save you the trouble of installing folder level scripts on the user's system. 

 

 

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines