error when open new window and open pdf

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

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

Post Reply
tamiHoltzer
User
Posts: 2
Joined: Tue May 29, 2018 11:26 am

error when open new window and open pdf

Post by tamiHoltzer » Tue May 29, 2018 11:57 am

Hi
I have web-app that contain java-script that load pdf to html object tag :
when the user press a button I perform java-script code that close the pdf opened in the main window and then open it in the new window.
this code sometimes fails , I think that is due to synchronization problems , when I refresh the new window (that failed) - it succeed to open the file.

the code from the main window :

Code: Select all

function open_file_not_allow_edit()  
{
	try {
 		
	       var pdf = document.getElementById("documentAction:pdfPath");
	       var allowEdit = document.getElementById("documentAction:AllowEditPdfFlag");
	       var PDFView1 = document.getElementById("PDFView");
	       if(PDFView1==null)
	       {
		  			PDFView1 = document.getElementById("documentAction:PDFView");
	       }
	     
	       if(pdf!=null)
	  	   {
	  	  		var val = pdf.value;
	  	  		
	  	  	// registeration key (license for our Viewer AX SDK.)   SetDevInfo(serial key ,developer code )		  			
	  	  	PDFView1.SetDevInfo("xxx","xxx"); 

	
	  	  		PDFView1.OpenDocument(val, 0, 0, 0); // open the file
	  	  	   	docID = PDFView1.Property("Documents.Active", 0);
	  	  	   	if(allowEdit.value == "false" )
		         {
		  	  		PDFView1.SetDocumentProperty(docID, "ReadOnly", "true", 0); // disables editing for specified document
		  	  	 }
		  	}		
	          
	      }
	      catch (err) {
	    	//  alert('error in opening file');
	    	//  alert(err.message);
	      }

}
on the new window I have :

Code: Select all

  window.onload = function(evt){
    	  try {
    		
		       var PDFView1 = document.getElementById("PDFView");
		       var pdf = document.getElementById("documentAction:pdfPath");
		       var val = pdf.value;
		    
		       // registeration key (license for our Viewer AX SDK.)   SetDevInfo(serial key ,developer code )		  			
		  	  	PDFView1.SetDevInfo("xxx","xxx"); 

		       PDFView1.OpenDocument(val, 0, 0, 0); // open the file

		      docID = PDFView1.Property("Documents.Active", 0);
		      
			  PDFView1.SetDocumentProperty(docID, "ReadOnly", "false", 0); // disables editing for specified document
			  PDFView1.DoVerb("", "ExecuteCommand", "ToggleAllBars", 0, 0);
			  PDFView1.SetProperty("View.Bars[\"CommentAndMarkup\"].Visible", "true");// add comments toolbar
			  PDFView1.SetProperty("View.Bars[\"Menu\"].Visible", "true");// add Menu toolbar
			  PDFView1.SetProperty("View.Bars[\"RotateView\"].Visible", "true");// add RotateView toolbar
			  PDFView1.SetProperty("View.Bars[\"Standard\"].Visible", "true");// add Standard toolbar
			  PDFView1.SetProperty("View.Bars[\"Zoom\"].Visible", "true");// add Zoom toolbar
			  
			//	enable keyboard shortcuts like : "Ctlr+c , Ctrl+v ..." 
			  PDFView1.SetProperty("General.AllowAllAccelerators", "true");
						  
		}
		catch (err) {
		    	 
		}
      } // window.onload finish
any Idea what is cousing the problem and how can I fix it?

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

Re: error when open new window and open pdf

Post by Tracker Supp-Stefan » Tue May 29, 2018 12:26 pm

Hello tamiHoltzer,

I will move your topic to the Viewer AX SDK forum where it belongs, and will pass this topic to a colleague from our dev team who will assist with your enquiry.

Regards,
Stefan

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1923
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: error when open new window and open pdf

Post by Vasyl-Tracker Dev Team » Tue May 29, 2018 10:35 pm

Hi TamiHoltzer.

Its hard to say without working example where is problem exactly..
Anyway, please try slightly change order: firstly open new window and then close main window. Also when you closing window please try firstly close the document opened in that window by:

PDFView.CloseDocument(0, 10); // 0x2 - NoUI flag | 0x8 - synchronous flag (see PXCVA_Flags enum)

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

tamiHoltzer
User
Posts: 2
Joined: Tue May 29, 2018 11:26 am

Re: error when open new window and open pdf

Post by tamiHoltzer » Thu May 31, 2018 10:46 am

I tried that , but it did't help .
were can I find documentation about how to use javascript to manipulate the object ( to perform more functions , use properties )
I.e I wish to check how many doc are opened how can I do thie in my Javascript code?

thanks
Tami

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1923
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: error when open new window and open pdf

Post by Vasyl-Tracker Dev Team » Fri Jun 15, 2018 11:37 pm

Hi TamiHoltzer.
were can I find documentation about how to use javascript to manipulate the object ( to perform more functions , use properties )
There is description of Viewer's objects hierarchy:
https://help.tracker-software.com/DEV/d ... medobjects

You may use pdfCtl.Property to get access to such objects.
I.e I wish to check how many doc are opened how can I do thie in my Javascript code?
Not sure that it will help you in your case. By default each instance of pdfControl is single document and all instances of control are isolated/independent from each other.
So, for example, if you have two pdf-controls with opened document in each and then if you ask each control about opened documents count - it will return 1. But technically in your app you have opened 2 documents in 2 controls:

Code: Select all

(pdfCtl1.Property["Documents.Count"] + pdfCtl2.Property["Documents.Count"]) == 2
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

Post Reply