Skip to main content
daitranthanhoa
Inspiring
July 7, 2023
Question

Why does Acrobat Pro DC 2023 64bit hang while running a script?

  • July 7, 2023
  • 2 replies
  • 1831 views

I had create a sample data test at.

https://drive.google.com/file/d/1sTILHTJAtqSZwc4PmCifKmf0GznoZuxp/view?usp=sharing

 

This is my script ( run script from console window of Acrobat): 

 

var link_info = "";
var ckWord ;	
var iPageGoto;
for (var p = 0; p < 200; p++)
{
    var numWords = this.getPageNumWords(p);

	var st=new Date();
	console.println(p + st);

		for (var i=0; i<numWords; i++)
		{       
			 ckWord = this.getPageNthWord(p, i, false); 
			if (ckWord.search("P\\.")>=0)
						{
				iPageGoto =this.getPageNthWord(p, i+1, true);
				
				if(iPageGoto>0)
				{
				   link_info +=iPageGoto;
				}
				iPageGoto=null;
			}
			ckWord=null;			
				
		}	

}
event.value = link_info;

 

 

This is result of Acrobat Pro 2023 64 bit: Time is 1h 11' 

It hang at Page 137

 

var link_info = "";
var ckWord ;	
var iPageGoto;
for (var p = 0; p < 200; p++)
{

    var numWords = this.getPageNumWords(p);

	var st=new Date();
	console.println(p + st);
	


		for (var i=0; i<numWords; i++)
		{       
			 ckWord = this.getPageNthWord(p, i, false); 
			if (ckWord.search("P\\.")>=0)
						{
				iPageGoto =this.getPageNthWord(p, i+1, true);
				
				if(iPageGoto>0)
				{
				   link_info +=iPageGoto;
				}
				iPageGoto=null;
			}
			ckWord=null;
			
				
		}
	

}

event.value = link_info;
0Tue Jul 04 2023 16:22:32 GMT+0700 (SE Asia Standard Time)
1Tue Jul 04 2023 16:22:32 GMT+0700 (SE Asia Standard Time)
2Tue Jul 04 2023 16:22:32 GMT+0700 (SE Asia Standard Time)
3Tue Jul 04 2023 16:22:32 GMT+0700 (SE Asia Standard Time)
...
133Tue Jul 04 2023 16:22:42 GMT+0700 (SE Asia Standard Time)
134Tue Jul 04 2023 16:22:42 GMT+0700 (SE Asia Standard Time)
135Tue Jul 04 2023 16:22:43 GMT+0700 (SE Asia Standard Time)
136Tue Jul 04 2023 16:22:43 GMT+0700 (SE Asia Standard Time)
137Tue Jul 04 2023 16:22:43 GMT+0700 (SE Asia Standard Time)
138Tue Jul 04 2023 17:33:32 GMT+0700 (SE Asia Standard Time)
139Tue Jul 04 2023 17:33:32 GMT+0700 (SE Asia Standard Time)
...
198Tue Jul 04 2023 17:33:37 GMT+0700 (SE Asia Standard Time)
199Tue Jul 04 2023 17:33:37 GMT+0700 (SE Asia Standard Time)

 

 

 

This is result of Acrobat Pro 2023 32 bit: Time only is 2'

 

var link_info = "";
var ckWord ;	
var iPageGoto;
for (var p = 0; p < 200; p++)
{

    var numWords = this.getPageNumWords(p);
	var st=new Date();
	console.println(p + st);

	for (var i=0; i<numWords; i++)
	{       
		 ckWord = this.getPageNthWord(p, i, false); 
		if (ckWord.search("P\\.")>=0)
					{
			iPageGoto =this.getPageNthWord(p, i+1, true);
			
			if(iPageGoto>0)
			{
			   link_info +=iPageGoto;
			}
			iPageGoto=null;
		}
		ckWord=null;		
			
	}	

}

event.value = link_info;
0Tue Jul 04 2023 16:21:46 GMT+0700 (SE Asia Standard Time)
1Tue Jul 04 2023 16:21:46 GMT+0700 (SE Asia Standard Time)
2Tue Jul 04 2023 16:21:46 GMT+0700 (SE Asia Standard Time)
3Tue Jul 04 2023 16:21:46 GMT+0700 (SE Asia Standard Time)
...
132Tue Jul 04 2023 16:22:04 GMT+0700 (SE Asia Standard Time)
133Tue Jul 04 2023 16:22:04 GMT+0700 (SE Asia Standard Time)
134Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
135Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
136Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
137Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
138Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
139Tue Jul 04 2023 16:22:05 GMT+0700 (SE Asia Standard Time)
...
196Tue Jul 04 2023 16:22:15 GMT+0700 (SE Asia Standard Time)
197Tue Jul 04 2023 16:22:15 GMT+0700 (SE Asia Standard Time)
198Tue Jul 04 2023 16:22:16 GMT+0700 (SE Asia Standard Time)
199Tue Jul 04 2023 16:22:16 GMT+0700 (SE Asia Standard Time)

 

 

 

 

 

Environment: [Win 10 64bit + Ram 8G + I3] or [Win 10 64bit + Ram 16G + I7]

 

I had try uncheck Security (Enhanced)>"Enable Protected Mode at Start-up" and "Enable Enhanced Sercurity", But it is not ok

 

Why does Acrobat Pro DC 2023 64bit hang while running a script?

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 10, 2023

I modified your code to print link_info to the console, and only print out the start and end times, and ran it on the file you shared in Acrobat XI. Runtime was ~15 seconds.

daitranthanhoa
Inspiring
July 11, 2023

Yes, Acrobat XI is Ver 32bit. 

 it only occur with Ver 64bit (Pro DC 2022 64bit, Pro DC 2023 64bit)

daitranthanhoa
Inspiring
July 13, 2023

@Amal. 

@S. S 

Is there any solution for this problem?

Thom Parker
Community Expert
Community Expert
July 7, 2023

Is this script being run from inside a field? or from the console window?

 

There are a couple of issues with the code, but nothing that would cause the problemw you've described. Text extraction has gotten slower and more buggy with each new version.  In Acrobat 9 it was blazing fast and has gone down hill quickly since then. 

 

Why is the number of pages hard coded?  

Use this instead:

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

 

This line is a possible problem because the next word might not exist:

			iPageGoto =this.getPageNthWord(p, i+1, true);

 

Use this instead

   			if(++1 < numWords)
   			   iPageGoto =this.getPageNthWord(p, i, true);
   			else
   			   continue;

 

However, the most likely issue causing Acrobat to crash is that the JS engine is running out of resources. Text extraction is memory intensive. You might try freeing up memory by deleting the word variables. I doubt this will help much. 

 

delete ckWord;

delete iPageGoto;

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
daitranthanhoa
Inspiring
July 10, 2023

I run script  from the console window.

I'm testing , so setting 200 pages to limit time.

I had try add, but it still not ok.

delete ckWord;

delete iPageGoto;

 

And I confirmed, it only happens with Version 64bit .

Ver: Pro X,  Pro DC 2015, Pro DC 2023 32 bit => It is ok.

Ver: Pro DC 2022 64bit, Pro DC 2023 64bit => It hang very long.

 

Thom Parker
Community Expert
Community Expert
July 10, 2023

I think this is a problem with Acrobat that you might not be able to get past.

I would try limiting the run to 100 pages at a time. See if just doing it in batches works.   

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often