mirror of
https://github.com/nasa/openmct.git
synced 2025-01-03 03:46:42 +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",
|
"node-uuid": "^1.4.7",
|
||||||
"comma-separated-values": "^3.6.4",
|
"comma-separated-values": "^3.6.4",
|
||||||
"FileSaver.js": "^0.0.2",
|
"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",
|
"angular-route": "bower_components/angular-route/angular-route.min",
|
||||||
"csv": "bower_components/comma-separated-values/csv.min",
|
"csv": "bower_components/comma-separated-values/csv.min",
|
||||||
"es6-promise": "bower_components/es6-promise/promise.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": "bower_components/moment/moment",
|
||||||
"moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format",
|
"moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format",
|
||||||
"saveAs": "bower_components/FileSaver.js/FileSaver.min",
|
"saveAs": "bower_components/FileSaver.js/FileSaver.min",
|
||||||
@ -43,6 +45,9 @@ requirejs.config({
|
|||||||
"angular-route": {
|
"angular-route": {
|
||||||
"deps": ["angular"]
|
"deps": ["angular"]
|
||||||
},
|
},
|
||||||
|
"html2canvas": {
|
||||||
|
"exports": "html2canvas"
|
||||||
|
},
|
||||||
"moment-duration-format": {
|
"moment-duration-format": {
|
||||||
"deps": ["moment"]
|
"deps": ["moment"]
|
||||||
},
|
},
|
||||||
@ -59,6 +64,8 @@ define([
|
|||||||
'./platform/framework/src/Main',
|
'./platform/framework/src/Main',
|
||||||
'legacyRegistry',
|
'legacyRegistry',
|
||||||
|
|
||||||
|
'html2canvas',
|
||||||
|
'jspdf',
|
||||||
'./platform/framework/bundle',
|
'./platform/framework/bundle',
|
||||||
'./platform/core/bundle',
|
'./platform/core/bundle',
|
||||||
'./platform/representation/bundle',
|
'./platform/representation/bundle',
|
||||||
@ -95,6 +102,18 @@ define([
|
|||||||
'./platform/status/bundle',
|
'./platform/status/bundle',
|
||||||
'./platform/commonUI/regions/bundle'
|
'./platform/commonUI/regions/bundle'
|
||||||
], function (Main, legacyRegistry) {
|
], 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 {
|
return {
|
||||||
legacyRegistry: legacyRegistry,
|
legacyRegistry: legacyRegistry,
|
||||||
run: function () {
|
run: function () {
|
||||||
|
@ -54,7 +54,7 @@ define(
|
|||||||
* @throws {Error} an error is thrown if WebGL is unavailable.
|
* @throws {Error} an error is thrown if WebGL is unavailable.
|
||||||
*/
|
*/
|
||||||
function GLChart(canvas) {
|
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,
|
vertexShader,
|
||||||
fragmentShader,
|
fragmentShader,
|
||||||
program,
|
program,
|
||||||
|
Loading…
Reference in New Issue
Block a user