From ed102492e5529c0d840f00f33121e0161fa7e4b9 Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Fri, 30 Sep 2016 12:49:02 -0700 Subject: [PATCH 1/2] [Bower] specify jspdf minor version Specify jsPDF minor version to avoid updating to v1.3.0, which appears to have problems with requirejs bundling. Fixes https://github.com/nasa/openmct/issues/1214 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 922eb905f3..7dbb8f9860 100644 --- a/bower.json +++ b/bower.json @@ -20,6 +20,6 @@ "FileSaver.js": "^0.0.2", "zepto": "^1.1.6", "html2canvas": "^0.4.1", - "jspdf": "^1.2.61" + "jspdf": "1.2.x" } } From ae6f6565fa61418406aafcad31d32e90c49fbb2f Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Fri, 30 Sep 2016 16:54:42 -0700 Subject: [PATCH 2/2] [export] remove pdf export Remove pdf export with extreme prejudice due to issues with build process. Fixes https://github.com/nasa/openmct/issues/1217 --- bower.json | 3 +-- main.js | 4 ---- platform/features/plot/bundle.js | 10 -------- .../features/plot/res/templates/plot.html | 5 ---- platform/features/plot/src/PlotController.js | 11 --------- .../plot/src/services/ExportImageService.js | 24 ++----------------- .../features/plot/test/PlotControllerSpec.js | 2 +- .../test/services/ExportImageServiceSpec.js | 21 ---------------- test-main.js | 1 - 9 files changed, 4 insertions(+), 77 deletions(-) diff --git a/bower.json b/bower.json index 7dbb8f9860..419871fe57 100644 --- a/bower.json +++ b/bower.json @@ -19,7 +19,6 @@ "comma-separated-values": "^3.6.4", "FileSaver.js": "^0.0.2", "zepto": "^1.1.6", - "html2canvas": "^0.4.1", - "jspdf": "1.2.x" + "html2canvas": "^0.4.1" } } diff --git a/main.js b/main.js index 34d1afeeeb..6968d8ff26 100644 --- a/main.js +++ b/main.js @@ -29,7 +29,6 @@ requirejs.config({ "csv": "bower_components/comma-separated-values/csv.min", "es6-promise": "bower_components/es6-promise/es6-promise.min", "html2canvas": "bower_components/html2canvas/build/html2canvas.min", - "jsPDF": "bower_components/jspdf/dist/jspdf.debug", "moment": "bower_components/moment/moment", "moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format", "saveAs": "bower_components/FileSaver.js/FileSaver.min", @@ -48,9 +47,6 @@ requirejs.config({ "html2canvas": { "exports": "html2canvas" }, - "jsPDF": { - "exports": "jsPDF" - }, "moment-duration-format": { "deps": ["moment"] }, diff --git a/platform/features/plot/bundle.js b/platform/features/plot/bundle.js index 691e310791..ec4e6f375a 100644 --- a/platform/features/plot/bundle.js +++ b/platform/features/plot/bundle.js @@ -146,16 +146,6 @@ define([ "copyright": "Copyright © 2012 Niklas von Hertzen.", "license": "license-mit", "link": "https://github.com/niklasvh/html2canvas/blob/master/LICENSE" - }, - { - "name": "jsPDF", - "version": "1.2.61", - "author": "James Hall", - "description": "JavaScript HTML renderer", - "website": "https://github.com/MrRio/jsPDF", - "copyright": "Copyright © 2010-2016 James Hall", - "license": "license-mit", - "link": "https://github.com/MrRio/jsPDF/blob/master/MIT-LICENSE.txt" } ] } diff --git a/platform/features/plot/res/templates/plot.html b/platform/features/plot/res/templates/plot.html index e25b582044..461389e2c1 100644 --- a/platform/features/plot/res/templates/plot.html +++ b/platform/features/plot/res/templates/plot.html @@ -23,11 +23,6 @@ class="abs holder holder-plot has-control-bar">
- - PDF - diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 3b23bce34a..b5af440731 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -368,17 +368,6 @@ define( return this.pending; }; - /** - * Export the plot to PDF - */ - PlotController.prototype.exportPDF = function () { - var self = this; - self.hideExportButtons = true; - self.exportImageService.exportPDF(self.$element[0], "plot.pdf").finally(function () { - self.hideExportButtons = false; - }); - }; - /** * Export the plot to PNG */ diff --git a/platform/features/plot/src/services/ExportImageService.js b/platform/features/plot/src/services/ExportImageService.js index d49adc15ec..8fa02c8bf5 100644 --- a/platform/features/plot/src/services/ExportImageService.js +++ b/platform/features/plot/src/services/ExportImageService.js @@ -26,32 +26,29 @@ define( [ "html2canvas", - "jsPDF", "saveAs" ], function ( html2canvas, - jsPDF, saveAs ) { var self = this; /** * The export image service will export any HTML node to - * PDF, JPG, or PNG. + * JPG, or PNG. * @param {object} $q * @param {object} $timeout * @param {object} $log * @param {constant} EXPORT_IMAGE_TIMEOUT time in milliseconds before a timeout error is returned * @constructor */ - function ExportImageService($q, $timeout, $log, EXPORT_IMAGE_TIMEOUT, injHtml2Canvas, injJsPDF, injSaveAs, injFileReader) { + function ExportImageService($q, $timeout, $log, EXPORT_IMAGE_TIMEOUT, injHtml2Canvas, injSaveAs, injFileReader) { self.$q = $q; self.$timeout = $timeout; self.$log = $log; self.EXPORT_IMAGE_TIMEOUT = EXPORT_IMAGE_TIMEOUT; self.html2canvas = injHtml2Canvas || html2canvas; - self.jsPDF = injJsPDF || jsPDF; self.saveAs = injSaveAs || saveAs; self.reader = injFileReader || new FileReader(); } @@ -128,23 +125,6 @@ define( } } - /** - * Takes a screenshot of a DOM node and exports to PDF. - * @param {node} element to be exported - * @param {string} filename the exported image - * @returns {promise} - */ - ExportImageService.prototype.exportPDF = function (element, filename) { - return renderElement(element, "jpeg").then(function (img) { - self.reader.readAsDataURL(img); - self.reader.onloadend = function () { - var pdf = new self.jsPDF("l", "px", [element.offsetHeight, element.offsetWidth]); - pdf.addImage(self.reader.result, "JPEG", 0, 0, element.offsetWidth, element.offsetHeight); - pdf.save(filename); - }; - }); - }; - /** * Takes a screenshot of a DOM node and exports to JPG. * @param {node} element to be exported diff --git a/platform/features/plot/test/PlotControllerSpec.js b/platform/features/plot/test/PlotControllerSpec.js index 73a01d716a..482af047cb 100644 --- a/platform/features/plot/test/PlotControllerSpec.js +++ b/platform/features/plot/test/PlotControllerSpec.js @@ -72,7 +72,7 @@ define( mockElement = angular.element('
'); mockExportImageService = jasmine.createSpyObj( "ExportImageService", - ["exportJPG", "exportPNG", "exportPDF"] + ["exportJPG", "exportPNG"] ); mockFormatter = jasmine.createSpyObj( "formatter", diff --git a/platform/features/plot/test/services/ExportImageServiceSpec.js b/platform/features/plot/test/services/ExportImageServiceSpec.js index 111a8d3432..675429f4e2 100644 --- a/platform/features/plot/test/services/ExportImageServiceSpec.js +++ b/platform/features/plot/test/services/ExportImageServiceSpec.js @@ -33,8 +33,6 @@ define( mockLog, mockHtml2Canvas, mockCanvas, - mockJsPDF, - mockJsPDFSave, mockSaveAs, mockFileReader, mockExportTimeoutConstant, @@ -79,13 +77,6 @@ define( "canvas", ["toBlob"] ); - mockJsPDFSave = jasmine.createSpy("jsPDFSave"); - mockJsPDF = function () { - return { - "addImage": function () {}, - "save": mockJsPDFSave - }; - }; mockSaveAs = jasmine.createSpy("saveAs"); mockFileReader = jasmine.createSpyObj( "FileReader", @@ -100,23 +91,11 @@ define( mockLog, mockExportTimeoutConstant, mockHtml2Canvas, - mockJsPDF, mockSaveAs, mockFileReader ); }); - it("runs html2canvas and tries to save a pdf", function () { - exportImageService.exportPDF(testElement, "plot.pdf"); - mockFileReader.onloadend(); - - expect(mockHtml2Canvas).toHaveBeenCalledWith(testElement, { onrendered: jasmine.any(Function) }); - expect(mockCanvas.toBlob).toHaveBeenCalledWith(mockDeferred.resolve, "image/jpeg"); - expect(mockDeferred.reject).not.toHaveBeenCalled(); - expect(mockJsPDFSave).toHaveBeenCalled(); - expect(mockPromise.finally).toHaveBeenCalled(); - }); - it("runs html2canvas and tries to save a png", function () { exportImageService.exportPNG(testElement, "plot.png"); diff --git a/test-main.js b/test-main.js index ff8a50ca6b..e006094a24 100644 --- a/test-main.js +++ b/test-main.js @@ -55,7 +55,6 @@ requirejs.config({ "csv": "bower_components/comma-separated-values/csv.min", "es6-promise": "bower_components/es6-promise/es6-promise.min", "html2canvas": "bower_components/html2canvas/build/html2canvas.min", - "jsPDF": "bower_components/jspdf/dist/jspdf.debug", "moment": "bower_components/moment/moment", "moment-duration-format": "bower_components/moment-duration-format/lib/moment-duration-format", "saveAs": "bower_components/FileSaver.js/FileSaver.min",