Page 1 of 1

error when open new window and open pdf

Posted: Tue May 29, 2018 11:57 am
by tamiHoltzer
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?

Re: error when open new window and open pdf

Posted: Tue May 29, 2018 12:26 pm
by Tracker Supp-Stefan
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

Re: error when open new window and open pdf

Posted: Tue May 29, 2018 10:35 pm
by Vasyl-Tracker Dev Team
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.

Re: error when open new window and open pdf

Posted: Thu May 31, 2018 10:46 am
by tamiHoltzer
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

Re: error when open new window and open pdf

Posted: Fri Jun 15, 2018 11:37 pm
by Vasyl-Tracker Dev Team
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.pdf-xchange.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.