Printing to PDF file

Hi Walter

I need your help in printing chart to pdf. I used below code to open chart for print but coming as blank window. any other reference JS i am missing, i have added goJs already. getting error at newDocument.body.appendChild(svg); please help.

myDiagram.model = new go.GraphLinksModel($scope.Employees, $scope.EmployeesRelations);
var button = document.getElementById(‘openSVG’);
button.addEventListener(‘click’, function() {
var newWindow = window.open("",“newWindow”);
if (!newWindow) return;
var newDocument = newWindow.document;
var svg = myDiagram.makeSvg();
newDocument.body.appendChild(svg);
}, false);

Did you start from the Minimal PDF sample at: Minimal GoJS Sample Generating PDF ?
The project is at: GoJS/projects/pdf at master · NorthwoodsSoftware/GoJS · GitHub

If so, could you please be more specific about what the problem is?

i put below code to print, everything is working in chrome but in IE it is not working , error coming at line $(svg).appendTo(idval), throwing jquery error also tried with document.body.appendChild(newHeading) but not working. do you have any idea.

And does go.js depend on any specific jQuery library, if so what is the least and what is the latest version of jquery it supports.

var button = document.getElementById('openSVG');
button.addEventListener('click', function() {  
	  var newWindow = window.open("","newWindow");
	  if (!newWindow) return;
	  var newDocument = newWindow.document;
	  var svg = myDiagram.makeSvg({ size: new go.Size(1000,1000) });
	  newDocument.write("<body id='id1'>StakeHolders Relationship Chart</body>");
	  var idval = newDocument.getElementById('id1');
	  //idval.appendChild(newParagraph);  
	  $(svg).appendTo(idval);
	   newWindow.print();
	   return false;
	}, false);

You might need to pass the document as an option to your call to Diagram.makeSvg.

No version of GoJS has ever depended on any version of jQuery. Or on any third-party library. Ever.

please share example code how to use document property in make svg

Just set the document property of the options argument to Diagram.makeSvg to refer to the window.document in which you want the SVG DOM to be. There’s an example at: GoJS Making SVG -- Northwoods Software

I got to know the issue is below code in IE is not generating complete svg. it just generating below given data. please help us.

code

var svg = myDiagram.makeSvg({
size: new go.Size(1000,1000)
});

out put in IE

out put in Chrome

I don’t know what the problem is with Internet Explorer there. Maybe this will help:

Or do your own searches of the web about this.