mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 22:17:49 +00:00
[Enhancement] Quick prototype of PDF export
This commit is contained in:
parent
4091e9cdf4
commit
852ac3cd55
@ -18,6 +18,8 @@
|
||||
"node-uuid": "^1.4.7",
|
||||
"comma-separated-values": "^3.6.4",
|
||||
"FileSaver.js": "^0.0.2",
|
||||
"zepto": "^1.1.6"
|
||||
"zepto": "^1.1.6",
|
||||
"html2canvas": "^0.4.1",
|
||||
"jspdf": "^1.2.61"
|
||||
}
|
||||
}
|
||||
|
19
main.js
19
main.js
@ -28,6 +28,8 @@ requirejs.config({
|
||||
"angular-route": "bower_components/angular-route/angular-route.min",
|
||||
"csv": "bower_components/comma-separated-values/csv.min",
|
||||
"es6-promise": "bower_components/es6-promise/promise.min",
|
||||
"html2canvas": "bower_components/html2canvas/build/html2canvas.min",
|
||||
"jspdf": "bower_components/jspdf/dist/jspdf.min",
|
||||
"moment": "bower_components/moment/moment",
|
||||
"moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format",
|
||||
"saveAs": "bower_components/FileSaver.js/FileSaver.min",
|
||||
@ -43,6 +45,9 @@ requirejs.config({
|
||||
"angular-route": {
|
||||
"deps": ["angular"]
|
||||
},
|
||||
"html2canvas": {
|
||||
"exports": "html2canvas"
|
||||
},
|
||||
"moment-duration-format": {
|
||||
"deps": ["moment"]
|
||||
},
|
||||
@ -59,6 +64,8 @@ define([
|
||||
'./platform/framework/src/Main',
|
||||
'legacyRegistry',
|
||||
|
||||
'html2canvas',
|
||||
'jspdf',
|
||||
'./platform/framework/bundle',
|
||||
'./platform/core/bundle',
|
||||
'./platform/representation/bundle',
|
||||
@ -95,6 +102,18 @@ define([
|
||||
'./platform/status/bundle',
|
||||
'./platform/commonUI/regions/bundle'
|
||||
], function (Main, legacyRegistry) {
|
||||
setTimeout(function() {
|
||||
var plotEl = document.getElementsByClassName('gl-plot')[0];
|
||||
|
||||
html2canvas(plotEl, {
|
||||
onrendered: function(htmlCanvas) {
|
||||
var pdf = new jsPDF('l', 'px', [plotEl.offsetHeight, plotEl.offsetWidth]);
|
||||
pdf.addImage(htmlCanvas.toDataURL('image/jpeg', 2.0), 'JPEG', 0, 0, plotEl.offsetWidth, plotEl.offsetHeight);
|
||||
pdf.save("plot.pdf");
|
||||
}
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
return {
|
||||
legacyRegistry: legacyRegistry,
|
||||
run: function () {
|
||||
|
@ -54,7 +54,7 @@ define(
|
||||
* @throws {Error} an error is thrown if WebGL is unavailable.
|
||||
*/
|
||||
function GLChart(canvas) {
|
||||
var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"),
|
||||
var gl = canvas.getContext("webgl", { preserveDrawingBuffer: true }) || canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }),
|
||||
vertexShader,
|
||||
fragmentShader,
|
||||
program,
|
||||
|
Loading…
Reference in New Issue
Block a user