Highlighted

How can I programmatically set Document Properties > Initial View?

New Here ,
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, How to

Views

93

Likes

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

How can I programmatically set Document Properties > Initial View?

New Here ,
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, How to

Views

94

Likes

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
Sep 28, 2020 0
Adobe Community Professional ,
Sep 28, 2020

Copy link to clipboard

Copied

You can't set Initial View using JavaScript

Likes

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
Reply
Loading...
Sep 28, 2020 0
Adobe Community Professional ,
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...

Likes

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
Reply
Loading...
Sep 28, 2020 0
Eric5EBB LATEST
New Here ,
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.

Likes

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
Reply
Loading...
Sep 28, 2020 0
Adobe Community Professional ,
Sep 28, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Sep 28, 2020 0