Hi,
Smartcient version: Version v10.1p_2016-02-02/Enterprise Development Only (2016-02-02)
Browser version: Chrome Version 50.0.2661.94 m
We have a requirement to display pdf content in the browser. For business reasons we've decided to use a javascript library to display the content. This library is capable of rendering a base64 dataurl directly into a HTML5 <canvas>. So I have managed to do this by simply creating a Smartclient canvas object and setting the contents to a "canvas" as seen below.
In a separate method I'm then able to get this canvas (with a unique id) and it's context and pass that to the pdf renderer as follows:
The problem I have with the above is that if the canvas gets redrawn or re-arranged etc, the rendered pdf disappears (because it's not part of the newsStoryPDF widget I suppose).
So my question is, is this the right way of going about the problem or are there better ways of rendering pdfs using other Smartclient classes?
Smartcient version: Version v10.1p_2016-02-02/Enterprise Development Only (2016-02-02)
Browser version: Chrome Version 50.0.2661.94 m
We have a requirement to display pdf content in the browser. For business reasons we've decided to use a javascript library to display the content. This library is capable of rendering a base64 dataurl directly into a HTML5 <canvas>. So I have managed to do this by simply creating a Smartclient canvas object and setting the contents to a "canvas" as seen below.
Code:
this.newsStoryPDF = isc.Canvas.create({ overflow: "auto", height: "*", getInnerHTML: function(){ return "<canvas id='" + this.getID() + "_pdfcanvas' style='border: 1px solid blue;'></canvas>"; } });
Code:
... // get the JS canvas and canvas context var canvasForPDF = this.newsStoryPDF.getContentElement().getElementsByTagName("canvas")[0]; var canvasContextForPDF = canvasForPDF.getContext("2d"); // object required by the pdf renderer method which contains a property for the canvas context var renderContext = { context: canvasContextForPDF viewport: someViewport // just for illustration, }; ... load the pdf dataURL etc ... // finaly pass the canvas context to the pdf library method to render it pdflibrary.page.render(renderContext); // this successfully renders the pdf to the canvas ...
So my question is, is this the right way of going about the problem or are there better ways of rendering pdfs using other Smartclient classes?
Comment