Skip to main content
daitranthanhoa
Inspiring
February 2, 2018
Question

Why display message confirm save after ExecuteThisJavascript?

  • February 2, 2018
  • 2 replies
  • 706 views

Dim iTotalPage = gPdDoc.GetNumPages

For iPage = 0 To iTotalPage - 1

        Dim formApp As AFORMAUTLib.AFormApp

        formApp = CreateObject("AFormAut.App")      

        Dim fields As AFORMAUTLib.Fields

        fields = formApp.Fields

        Dim strScript As String

        Dim tmp = "var p=" & iPage & ";" & vbNewLine

        strScript = tmp & System.IO.File.ReadAllText("Script.txt")

        ' call the method to execute JavaScript

        fields.ExecuteThisJavascript(strScript)             

Next

[Script.txt] process add link to target page.

After call process of Page=0, it display message confirm save. i not call command close document.

I repaired a document that was not properly saved before Adobe Acrobat shut down. To open the restored document, click "Yes". If you click "No", changes will be lost.

Why?

This topic has been closed for replies.

2 replies

Legend
February 2, 2018

I don’t know the cause but the form OLE objects are global and should be instantiated only once, outside the loop.

daitranthanhoa
Inspiring
February 2, 2018

i had try move to outside loop:

Dim formApp As AFORMAUTLib.AFormApp

formApp = CreateObject("AFormAut.App")     

Dim fields As AFORMAUTLib.Fields

ields = formApp.Fields

result: i run time 1 it is ok.

But if i run again, it will show message confirm save, after ExecuteThisJavascript some Pages.

try67
Community Expert
Community Expert
February 2, 2018

It would be helpful if we knew what your code actually does...

daitranthanhoa
Inspiring
February 2, 2018

this my script:

//for (var p = 0; p < this.numPages; p++)

//{

    var numWords = this.getPageNumWords(p);

var bLink=false;

    for (var i=0; i<numWords; i++)

    {

            var ckWord = this.getPageNthWord(p, i, false);

            if ( ckWord == "P."))

            {

 

var q = this.getPageNthWordQuads(p, i);

m = (new Matrix2D).fromRotated(this,p);

mInv = m.invert();

r = mInv.transform(q);

r=r.toString();

r = r.split(",");

var q2 = this.getPageNthWordQuads(p, i+1);

m2 = (new Matrix2D).fromRotated(this,p);

mInv2 = m2.invert()

r2 = mInv.transform(q2);

r2=r2.toString();

r2 = r2.split(",");

l = addLink(p, [r[4], r[5], r2[2], r2[3]]);

l.borderColor = color.red;

l.borderWidth = 1;

l.setAction("this.pageNum = 1" );

            }

    }

//}