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

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

Participant ,
Dec 20, 2024 Dec 20, 2024

Copy link to clipboard

Copied

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

TOPICS
PDF

Views

150

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
1 ACCEPTED SOLUTION
Adobe Employee ,
Dec 20, 2024 Dec 20, 2024

Copy link to clipboard

Copied

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

View solution in original post

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
Adobe Employee ,
Dec 20, 2024 Dec 20, 2024

Copy link to clipboard

Copied

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

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
Participant ,
Dec 21, 2024 Dec 21, 2024

Copy link to clipboard

Copied

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/147...
but I just want to try to implement this function by VBscript on a windows pc

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
Participant ,
Dec 26, 2024 Dec 26, 2024

Copy link to clipboard

Copied

LATEST

Hi Souvik,

when I reset security,  add folder path to trust ,  now I can process preflight via vbscript.


Set pdDoc = avDoc.GetPDDoc
Set jsObj = pdDoc.GetJSObject
Dim jsCode
jsCode = "var oProfile = Preflight.getProfileByName('Convert fonts to outlines'); var myPreflightResult = this.preflight( oProfile);"
AForm.Fields.ExecuteThisJavaScript jsCode

 

ruihuang_0-1735284640727.png

 

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