Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Print Diagram (Read 1475 times)
YaBB Newbies

I Love MindFusion!

Posts: 9
Location: pune
Joined: Sep 14th, 2018
Print Diagram
Jan 22nd, 2020 at 7:08am
Print Post  
Hello Team,

Is there any API in Mindfusion diagrams in JavaScript to print the diagram in PDF?

Swapnil Thosar
Back to top
IP Logged
YaBB Moderator

Posts: 2362
Joined: Oct 19th, 2005
Re: Print Diagram
Reply #1 - Jan 22nd, 2020 at 9:28am
Print Post  

We have PdfExporter class in our Java and .NET libraries, you could use it on server side if running these platforms on the server.

Other than that you could add the diagram as bitmap to a PDF page as shown here -

I've also played a bit with canvas2pdf library from second SO answer to export as vector graphics (the apply and lineWidth things are to work around some unimplemented method exceptions) -

Select All
//Create a new PDF canvas context.
var pdfContext = new canvas2pdf.PdfContext(blobStream());
pdfContext.doc.lineWidth = function () { return 1; }

var canvasContext = diagram.context;
pdfContext.transform = { apply: function() {} };
diagram.context = pdfContext;
diagram.context = canvasContext;

//convert your PDF to a Blob and save to file'finish', function ()
	var blob ='application/pdf');
	saveAs(blob, 'example.pdf', true);

but then it crashes on some code for embedding font files into the PDF, maybe you could get that to run if you set up the font files along with you project.

Back to top
IP Logged
Page Index Toggle Pages: 1
Send TopicPrint