JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
User avatar
AndyK
User
Posts: 102
Joined: Sun Jul 27, 2008 8:52 pm

JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by AndyK »

Hi,

since PDF-XChange Editor 9.0.353 my JavaScript buttons for printing all opened documents don't work anymore.
I had create two buttons - one for printing with dialog and one for printing without dialog.
  
JavaScriptPrinting.png
JavaScriptPrinting.png (21.27 KiB) Viewed 2067 times

printAllOpenedDocs!.zip
(31.92 KiB) Downloaded 51 times

How can I resolve these issues?

Many thanks
Andy
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Tracker Supp-Stefan »

Hello AndyK,

I can confirm that my similar script has also stopped working!
Checking with our devs now on what is causing this!

Kind regards,
Stefan
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Ivan - Tracker Software »

In build 353 we implemented proper handling of doc.disclosed property, as a result, app.activeDocs property returns an empty array.

In build 355 we will release implementation of app.trustedFunction, app.beginPriv, and app.endPriv methods which will allow to make your code work after some modifications.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
User avatar
AndyK
User
Posts: 102
Joined: Sun Jul 27, 2008 8:52 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by AndyK »

Hi Ivan,

when did you plan to release build 535?

Thanks
Andy
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by TrackerSupp-Daniel »

Hi, AndyK

We do not yet have a timeline for when 355 will be released, but as we just released build 354 last week, it will not likely be in the next few weeks. You will be looking forward probably a month or more.

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Puffolino
User
Posts: 317
Joined: Wed Feb 09, 2011 1:06 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Puffolino »

Hi,

is there a simple workaround to modify scripts like this... :roll:

Code: Select all

{
	var ad = app.activeDocs;
	
	if (ad.length)
	{
		for (var i = 0; i < ad.length; i++)
		{
			var pp = ad[i].info;
			var file=ad[i].documentFileName;
			//  :
			//  :
			//  :
		}
		console.println("ok");
	}
	else
	{
		app.alert({ 
		cMsg: "No pdf document has been loaded... @%$!",
		cTitle: "Information Cleaner", 
		nIcon: 3, nType: 0
		});
	}
}
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Tracker Supp-Stefan »

Hello Puffolino,

I am afraid that no - there's no solution in the current build, or we would have provided it already ;)

Kind regards,
Stefan
Mathew
User
Posts: 204
Joined: Thu Jun 19, 2014 7:30 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Mathew »

My workaround is to paste the script into the javascript console (CTRL+J) and run it from there. A bit of a pain, but the script can access the current documents.
User avatar
Ovg
User
Posts: 461
Joined: Tue Sep 05, 2017 4:56 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Ovg »

Working fine from console on all open documents: (at least for me)

Code: Select all

var ad = app.activeDocs;
var t = app.thermometer; // Acquire a thermometer object
t.duration = ad.length;
t.begin();
for (var i = 0; i < ad.length; i++)
{
  t.text = "Print Document # " + (i+1);
  t.value = i;
  if (typeof ad[i].numPages != "undefined")
  {
    var pp = ad[i].getPrintParams();
    // uncomment the next line to print without dialog for each document
    // pp.interactive = pp.constants.interactionLevel.silent;
    ad[i].print(pp);
  }
}
t.end();
It's impossible to lead us astray for we don't care even to choose the way.
PDF-XChange PRO, 10.1.1 (Build 381) / W7 SP1 x64
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Tracker Supp-Stefan »

Hello Ovg,

Yes - the console is with different permissions than when you add the script to a button!
As stated above - we are aware of this and with some modifications to the code from build 355 such JS code will be able to work correctly through a toolbar button once again.

Kind regards,
Stefan
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6837
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Paul - Tracker Supp »

Does 356 work for you guys?
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
User avatar
AndyK
User
Posts: 102
Joined: Sun Jul 27, 2008 8:52 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by AndyK »

Paul - Tracker Supp wrote: Thu Jul 22, 2021 9:45 pm Does 356 work for you guys?
Yes, with a new script from Stefan, but unfortunately without toolbar buttons.
https://forum.pdf-xchange.com/viewtopic.php?p=152500#p152500

═══

I would be really happy if this feature would be integrated directly into PDF-XChange Editor. So such programming laymen like me would not have to deal with such code.
Last edited by AndyK on Fri Jul 23, 2021 4:54 pm, edited 5 times in total.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Tracker Supp-Stefan »

Hello AndyK,

As mentioned in the other topic - the "silent" printing can not be made to work through a button any more - as we are now following the specification more strictly, and it explicitly states that "intents" can not work for JS added buttons.

Kind regards,
Stefan
User avatar
Ovg
User
Posts: 461
Joined: Tue Sep 05, 2017 4:56 pm

Re: JavaScript - printAllOpenedDocs dont work anymore since v9.0.353

Post by Ovg »

Thanks for fixing, working fine now!!!
It's impossible to lead us astray for we don't care even to choose the way.
PDF-XChange PRO, 10.1.1 (Build 381) / W7 SP1 x64
Post Reply