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

How can I programmatically set Document Properties > Initial View?

Community Beginner ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Question: How can I programmatically set Initial View settings while running a VBA macro?

Background: I'm working on an Excel tool that includes manipulating PDFs. I'm not an experienced programmer, but I've been able to figure out how to do the following via VBA:

  • Create bookmarks
  • Set document properties, e.g., Title, Author, Subject, etc.

I also found code that allows me to call JavaScript code with VBA, which I'm using to run a script (by Thom Parker) to clean up bookmarks. For reference, here's the VBA I'm using to call Javascript:

 

If avdoc.Open(File, "") Then
'//write JS-Code on a variable
Ex = " // Put JavaScript Code here...

'//Execute JS-Code
AForm.Fields.ExecuteThisJavaScript Ex
MsgBox ("Done")
End If

 

Additional Details:

  • It looks like I'm not able to do this with JavaScript, but is this correct? If I can set standard doc properties metadata, it seems to me that I ought to be able to set the Initial View settings??
  • I read that I'm not able to run an Action programmatically -- is that, in fact, the case? I've got an Action to do what I need.
  • I found lots of forum posts asking about manipulating PDFs that included responses saying, "Look at the SDK," but I've spent a ton of time looking through it but wasn't able to find anything.
  • I've learned that there is a ViewerPreferences dictionary in PDFs, but I can't find anything on how to manipulate its properties. If I can manipulate the metadata in the Info Dictionary, it would seem to me that I could similarly manipulate the ViewerPreferences dictionary??

 

So, I'm stumped but hopeful that there is some way in which I can set Initial Settings.

 

Thank you!

TOPICS
Acrobat SDK and JavaScript

Views

1.3K

Translate

Translate

Report

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 ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

You can't set Initial View using JavaScript

Votes

Translate

Translate

Report

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 ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Joel has already given you the answer to your question. Here is some additional information: Every time you say to yourself "I ought to be able...", you need to review the documentation. In this case, because you are trying to use the JavaScript API via the JSObject, you need to take a look at Acrobat's JavaScript API documentation, which you can find here:

 

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJ...

 

You may have to expand the table of contents on the left side to see the structure of the document. In this case, because you wnt to do something that is specific to a document, you would have to review the properties and methods of the "Doc" object. 

 

Just because you think somethign should be possible, does not necessarily mean that it actually is 🙂 I've fallen into that trap a few times myself...

Votes

Translate

Translate

Report

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 ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Thanks, all, for taking the time to respond.

Karl, regarding your closing sentence: yes, you are right. 🙂 Meanwhile, I will take a look at the Doc object, just to learn a bit more about it.

Votes

Translate

Translate

Report

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 ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

You can set the initial view with a plugin written in C/C++.

Votes

Translate

Translate

Report

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
New Here ,
Jun 06, 2023 Jun 06, 2023

Copy link to clipboard

Copied

Can you help with this plugin?  Do you have any pointers on what APIs this plugin might use?

Votes

Translate

Translate

Report

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 ,
Jun 06, 2023 Jun 06, 2023

Copy link to clipboard

Copied

The Acrobat plug-in SDK:

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/apireference/index.html

 

 

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

Votes

Translate

Translate

Report

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
LEGEND ,
Jun 07, 2023 Jun 07, 2023

Copy link to clipboard

Copied

LATEST

To use the plug-in API you need to know where in the PDF this info is stored, so you can use "Cos" methods to set these places. They are not stored in the Metadata or Info locations. The SDK should include the PDF specification (yes, over 1000 pages).

Votes

Translate

Translate

Report

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