Skip to main content
Inspiring
December 20, 2024
Answered

vbscript , function to "Preflight.getProfileByName('Convert fonts to outlines')"

  • December 20, 2024
  • 3 replies
  • 708 views

Hello, everyone,

What code should be added to achieve this function?

Dim gApp, avDoc
Set gApp = CreateObject("AcroExch.app")
Set avDoc = CreateObject("AcroExch.AVDoc")
Dim filepath
filepath = "C:\\test.pdf"
If avDoc.Open(filepath, "") = True Then
avDoc.BringToFront

 

' add vbscript code in here


avDoc.Close True 
Else
Msgbox "Failed to open PDF"
End If

Set pDDoc = Nothing
Set avDoc = Nothing
Set gApp = Nothing

This topic has been closed for replies.
Correct answer Souvik Sadhu

Hi @rui huang,

 

Hope you are doing well. Thanks for writing in!

 

Here is a sample code you might want to try.

 

 

Dim gApp, avDoc
Set gApp = CreateObject("AcroExch.App")
Set avDoc = CreateObject("AcroExch.AVDoc")
Dim filepath
filepath = "C:\\test.pdf"

If avDoc.Open(filepath, "") = True Then
    avDoc.BringToFront
    
    ' Note: This JavaScript cannot access Preflight
    Dim jsCode
    jsCode = "console.println('Preflight profiles are not accessible via JavaScript.');"
    
    ' Execute JavaScript in Acrobat
    Dim jsResult
    jsResult = avDoc.ExecuteThisJavaScript(jsCode)

    avDoc.Close True
Else
    Msgbox "Failed to open PDF"
End If

Set pDDoc = Nothing
Set avDoc = Nothing
Set gApp = Nothing

 

 

 

Note:

The code conceptually aligns with how you might combine VBScript and Acrobat's JavaScript API, but there are some issues and limitations to address for it to work correctly with Adobe Acrobat's API.

 

Key Considerations for Acrobat API:

 

1. app.execMenuItem('Preflight') in

  • This command opens the Preflight tool, but it does not directly access or run specific Preflight profiles.
  • The Preflight object and its methods (getProfileByName and run) are not accessible through JavaScript alone. They are part of the Acrobat SDK for creating custom plugins, which VBScript cannot invoke directly.

2. ExecuteThisJavaScript:

  • This method allows executing JavaScript, but JavaScript in Acrobat has limited access compared to plugins. Preflight profiles cannot be triggered this way.

 

3. VBScript and Preflight:

  • VBScript lacks direct access to the Preflight API in Acrobat. The Preflight API is available only through plugins written in C++ or via the Acrobat SDK.

 

Review the Acrobat SDK documentation to understand the capabilities and constraints of VBScript, JavaScript, and plugins.

 

Hope this helps.


-Souvik

3 replies

Souvik Sadhu
Souvik SadhuCorrect answer
Legend
December 20, 2024

Hi @rui huang,

 

Hope you are doing well. Thanks for writing in!

 

Here is a sample code you might want to try.

 

 

Dim gApp, avDoc
Set gApp = CreateObject("AcroExch.App")
Set avDoc = CreateObject("AcroExch.AVDoc")
Dim filepath
filepath = "C:\\test.pdf"

If avDoc.Open(filepath, "") = True Then
    avDoc.BringToFront
    
    ' Note: This JavaScript cannot access Preflight
    Dim jsCode
    jsCode = "console.println('Preflight profiles are not accessible via JavaScript.');"
    
    ' Execute JavaScript in Acrobat
    Dim jsResult
    jsResult = avDoc.ExecuteThisJavaScript(jsCode)

    avDoc.Close True
Else
    Msgbox "Failed to open PDF"
End If

Set pDDoc = Nothing
Set avDoc = Nothing
Set gApp = Nothing

 

 

 

Note:

The code conceptually aligns with how you might combine VBScript and Acrobat's JavaScript API, but there are some issues and limitations to address for it to work correctly with Adobe Acrobat's API.

 

Key Considerations for Acrobat API:

 

1. app.execMenuItem('Preflight') in

  • This command opens the Preflight tool, but it does not directly access or run specific Preflight profiles.
  • The Preflight object and its methods (getProfileByName and run) are not accessible through JavaScript alone. They are part of the Acrobat SDK for creating custom plugins, which VBScript cannot invoke directly.

2. ExecuteThisJavaScript:

  • This method allows executing JavaScript, but JavaScript in Acrobat has limited access compared to plugins. Preflight profiles cannot be triggered this way.

 

3. VBScript and Preflight:

  • VBScript lacks direct access to the Preflight API in Acrobat. The Preflight API is available only through plugins written in C++ or via the Acrobat SDK.

 

Review the Acrobat SDK documentation to understand the capabilities and constraints of VBScript, JavaScript, and plugins.

 

Hope this helps.


-Souvik

rui huangAuthor
Inspiring
December 21, 2024

Hi Souvik,
Thanks for your reply,

In fact, Preflight can be run via javascript on mac, pls see:
https://community.adobe.com/t5/acrobat-discussions/script-to-pdf-convert-all-text-to-outline/m-p/14742946
but I just want to try to implement this function by VBscript on a windows pc