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

How can extract all image by Javascipt?

Enthusiast ,
Mar 30, 2017 Mar 30, 2017

I can extract all image by menu of Acrobat:Tools >> Document Processing >> Export All Images.

But i want call this function from my app.

Can call action from javascript or extract all image by Javascipt?

TOPICS
Acrobat SDK and JavaScript
1.2K
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 ,
Mar 31, 2017 Mar 31, 2017

You can simulate pressing that button using JS, but it would still require user input to complete the project.

JS can't extract the images from a PDF on its own.

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 ,
Mar 31, 2017 Mar 31, 2017

You can try the export as HTML with the method saveAs.

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
Enthusiast ,
Mar 31, 2017 Mar 31, 2017

Can i save as html by script or COM?

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 ,
Mar 31, 2017 Mar 31, 2017

Use the JavaScript method saveAs.

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
Enthusiast ,
Apr 01, 2017 Apr 01, 2017

If i call this script: this.saveAs("/c/tmp/myDoc.html", "com.adobe.acrobat.html"); from Acrobat, It saved ok.

But If i call script from other Application, It can't saveAs.:

          Dim AForm = CreateObject("AFormAut.App")

          Dim test = "this.saveAs(""/c/tmp/myDoc.html"", ""com.adobe.acrobat.html"");"

          Dim b = AForm.Fields.ExecuteThisJavaScript(test)

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
LEGEND ,
Apr 01, 2017 Apr 01, 2017

Console messages?

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
Enthusiast ,
Apr 02, 2017 Apr 02, 2017

message is: undefined, but i check result output ok.

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
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Complete messages please, please copy/paste. The exact details matter. please make sure the messages come from running the external script NOT from your typed in commands (for which undefined is a normal response).

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
Enthusiast ,
Apr 03, 2017 Apr 03, 2017

i run from JavaScript Debugger:

this.saveAs("/c/tmp/myDoc.html","com.adobe.acrobat.html"); -> Press Ctrl+enter

undefined

If i run from Vb.net:

Dim AForm = CreateObject("AFormAut.App")

Dim test = "this.saveAs(""/c/tmp/myDoc.html"", ""com.adobe.acrobat.html"");"

Dim b = AForm.Fields.ExecuteThisJavaScript(test)

not show message.

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 ,
Apr 03, 2017 Apr 03, 2017

"undefined" just means the code executed without errors or returning any

values.

On Mon, Apr 3, 2017 at 10:42 AM, daitranthanhoa <forums_noreply@adobe.com>

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
LEGEND ,
Apr 03, 2017 Apr 03, 2017

You wrote "But If i call script from other Application, It can't saveAs.:"  What exactly do you mean by "can't"?

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
Enthusiast ,
Apr 03, 2017 Apr 03, 2017

If i run from Vb.net:

Dim AForm = CreateObject("AFormAut.App")

Dim test = "this.saveAs(""/c/tmp/myDoc.html"", ""com.adobe.acrobat.html"");"

Dim b = AForm.Fields.ExecuteThisJavaScript(test)

not show any message.

But result not output, have not file html, image.

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
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Ok, so the code appears to run, but it does not have the expected result.

Have you confirmed that other code is being run correctly if you use this ExecuteThisJavaScript method? A simple test is to run an app.alert in your code. For example

Dim test = "app.alert(""BEFORE""); <my code to try>; app.alert(""AFTER"")" ...

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
Enthusiast ,
Apr 03, 2017 Apr 03, 2017

try this code:

Dim test = "app.alert(""BEFORE""); this.saveAs(""/c/tmp/myDoc.html"", ""com.adobe.acrobat.html""); app.alert(""AFTER"")"

Dim b b = AForm.Fields.ExecuteThisJavaScript(test)

Result only show message: "BEFORE"

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 ,
Apr 03, 2017 Apr 03, 2017

Where are you opening the PDF file that you want to convert?

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
Enthusiast ,
Apr 03, 2017 Apr 03, 2017

   Dim oDoc As Acrobat.CAcroPDDoc = CreateObject("AcroExch.PDDoc")

   oDoc.Open("D:\1.ATTS_Next\DataTest\test1.pdf")

I try this script, it working ok:

Dim ex = " // set annot for text selection " & vbLf _

                            & "var sqannot = this.addAnnot({type: ""Square"", page: " & iPage & ", " & vbLf _

                            & "rect: [" & rect.left & ", " & rect.top & ", " & rect.right & ", " & rect.bottom & "], " & vbLf _

                            & "name: ""p" & iPage & "i" & i & """});"

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 ,
Apr 04, 2017 Apr 04, 2017
LATEST

You can use a try-catch-construct:

try {

... your code ...

} catch(e) {

for (var i in e) console.println( i + ': ' + e);

}

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