Canvas Printing Error

Hi Guys,

When I try to print I get the error message below.
Any ideas on what I am doing incorrectly?

Href & Browser URL:
href=“print.pdf?url=http%3A%2F%2Flocalhost%3A8080%2F%23%2FdashboardPDOUB&orientation=Landscape&page-size=A4”

Url:
http://localhost:8080/#/dashboardPDOUB

The error:

com.cubewise.j: [$controller:ctrlreg] The controller with the name ‘MainCtrl’ is not registered.
AngularJS
http://localhost:8080/assets/js/libs.2.0.20171129.js:1
http://localhost:8080/assets/js/libs.2.0.20171129.js : 1
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
TypeError: null is not an object (evaluating ‘content.textContent’)
undefined : 3
: 6
Failed to wait for the requested page to load

phantomjs://code/with-session.js:129 in checkPageReady

Some more information i have uncovered:

In the ‘with-session.js’ javascript file, which handles the a part of the printing, there is a document.getElementById function that is returning null:

with-session.js::

So the function is not picking up the ID tag from the index.ftl page, never reverts to ‘isReady=true’ and basically loops until it forces a time out error.

So I guess the page is not finished rendering on time when passed to phantomjs?

I’ve tried playing around with the setTimeout function timings/number of check loops but unfortunately get the same result as per first posting above.

More information:
If I look at the _invokeQueue property on the app object in the browser console, the ‘MainCtrl’ controller does seem to be registered as well:

Not sure where this error in post1 above originates from then?

Hi @gpool,

That could potentially be because of an erroneous client script. Or a heavy customization which might have touch off one of the Canvas maintained files. Another aspect would be a clash with one of the libraries built-in within Canvas.

Has the index.ftl been modified?

How about the page that is being printed, any error in the console when browsing to that page? How about the other pages? Or is the printing error only happening with this page?

The MainCtrl mostly deals with the menu.


Paul

@gpool @plim

I’m not sure if this is related, but we have seen similar errors with the PDF printing when a variable (like a title element) is bound to $uiPrefs (local storage).

Binding these variable to the scope of the page rather than the $rootScope of local storage removed our errors, but meant we had to work around the locally stored preferences requirement as a result.

Jack

@plim
Thanks Paul.
Yes, the index.ftl has been modified.
There is only one page.
Currently I have errors relating to the d3 library when browsing to the page (screenshot below) - they dont influence the page functionality…but could they impact on the printing?
(think its trying to draw the graphs/sliders before the data has arrived…)

@jtuckerman
Thanks Jack.
If I remember correctly there are no local variables bound to $uiPrefs currently…but I will doublecheck and make sure.

Hi Guys,

Thanks - you put me on the right track and I think I have identified the problem area:

I fixed the console errors, but the the printing problem was still the same.

However, In one part of the code I make a $rootScope.$broadcast from main.js down the scope to catch some functionality in my child controller.

When I disable this line of code, the printing works as expected.

Why would a $rootScope.$broadcast cause the printing to crash though?

That being said, is there a better alternative approach than a $rootscope.$broadcast to trigger functionality in the child controller?

Context:
The user adjusts values with sliders.
The user clicks a button - in the navigation bar at the top (main.js).
This button causes certain sliders to lock - so if the user drags a slider, another related slider will also move
This button currently fires a $broadcast down the scope

Hi @gpool,

That is great! Now, about that broadcast, it may not be the main issue as per what the nature of the error is:

TypeError: null is not an object (evaluating 'content.textContent')
undefined : 3

Can you post the lines of code that was added into the main.js file?

If not possible, try to check the value that is being broadcasted. It could be behaving differently when executing silently. I would imagine that it is extracting a property or value from a result / object - however, during this time, it may not be available yet.

An example would be:

// below line of code would throw out an error when the 'eventResponse' is null
$rootScope.$broadcast('event.to.broadcast', eventResponse.data);

Then for the $rootScope broadcast. depending on the location of your controller declaration, you should be able just $scope instead. This is normally the case when the child controller is encapsulated by the Parent HTML with the MainCtrl.


Paul

Hi @plim,

Below is the code currently - it was added below the existing main.js code right at the bottom of the file:

// set default flags
var EnableCommonPE = false;

// update flags
$scope.changeIconLock = function() {

	EnableCommonPE = !EnableCommonPE;

	// THIS SECTION SEEMS TO BE THE CULPRIT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<HERE
	/* broadcast to children so that can pick up there */ 
	$rootScope.$broadcast('commonLockChanged', { EnableCommonPE } );

}

The variable EnableCommonPE is first set to a default flag of ‘false’ though?
Or is this maybe a JS hoisting related issue that i am missing?

Regards,
Gerhard

Hi @gpool,

The parameter that you are broadcasting, looks not correct.

Nirmally, you would broadcast an object, which has a property and a value at least.

What you are broadcasting is in a wrong JSON format. It looks like you are trying to broadcast:

{true}

Instead of:

{prop:true}

So try to change that to a proper JSON object first and see if that helps.


Paul

@plim
That makes complete sense!
(double facepalm moment)

I adjusted it now and its working.

Super thanks for all the help!
Really appreciated.

1 Like