/*
* 专门负责导出流程图文件并让用户下载的扩展包方法,需要依赖:
* ../plugin/promise.min.js
* ../plugin/html2canvas.min.js
* ../plugin/canvg.js (当必须在IE11及以下版本的IE浏览器上运行时)
*/
GooFlow.prototype.exportDiagram = function (fileName) {
// 0.添加临时元素
var width = this.$workArea.width();
var height = this.$workArea.height();
$('body').append('
');
// 1.先COPY节点和区块的内容
var inner = $('#demo').find('.GooFlow_work_inner');
var divCanvas = $('#demo_export').children('div:eq(0)');
// 复制节点的内容
inner.children('div').each(function (i) {
var item = $(this);
if (item.hasClass('GooFlow_item')) {
item.clone().removeAttr('id').css('position', 'absolute').appendTo(divCanvas);
} else if (item.hasClass('GooFlow_work_group')) {
item.clone().removeAttr('id').css('position', 'absolute')
.attr('xmlns', 'http://www.w3.org/1999/xhtml').appendTo(divCanvas);
}
});
html2canvas(divCanvas[0], {
allowTaint: false,
taintTest: false,
onrendered: function (canvas) {
// 2.在回调方法中,COPY连线内容
// 造出临时的IMAGE
var context = canvas.getContext('2d');// 取得画布的2d绘图上下文
context.save();
var strSvg = '