From 60f7b4448f942983ebf002f511267ff2969e5d3a Mon Sep 17 00:00:00 2001 From: Samuel Rouse Date: Mon, 16 Jan 2017 19:56:13 -0500 Subject: [PATCH 1/4] Proposed fix for missing canvas content --- printThis.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/printThis.js b/printThis.js index 056797e..b8b4fb3 100644 --- a/printThis.js +++ b/printThis.js @@ -140,6 +140,12 @@ // print header if (opt.header) $body.append(opt.header); + // add canvas data-ids. + var canvasId = 0; + $element.find('canvas').each(function(){ + $(this).attr('data-printthis', canvasId++); + }); + // grab $.selector as container if (opt.printContainer) $body.append($element.outer()); @@ -148,6 +154,14 @@ $body.append($(this).html()); }); + // Re-draw "new" canvases + $body.find('canvas').each(function(){ + var cid = $(this).data('printthis'), + source = $('[data-printthis="' + cid + '"]')[0]; + + this.getContext('2d').drawImage(source, 0, 0); + }); + // capture form/field values if (opt.formValues) { // loop through inputs From 86cb4379db8bf4be21a4129d2d69134166ee9eb5 Mon Sep 17 00:00:00 2001 From: Samuel Rouse Date: Mon, 16 Jan 2017 23:27:40 -0500 Subject: [PATCH 2/4] 1.9.0 - Canvas updates --- changelog.txt | 3 +++ package.json | 2 +- printThis.jquery.json | 2 +- printThis.js | 39 ++++++++++++++++++++++++--------------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1d2b1ca..aad6203 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +01/16/2017 Added experimental canvas copy support. + Bumped to 1.9.0 for new feature (canvas). + 01/16/2017 Added footer as proposed in 2015 by @RomainGehrig Bumped version to 1.8.0 for new feature Corrected 1.7.1 changelog date to 01/15/2017 diff --git a/package.json b/package.json index bb0da09..5cb98e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "print-this", - "version": "1.8.0", + "version": "1.9.0", "description": "Printing plug-in for jQuery", "main": "printThis.js", "dependencies": { diff --git a/printThis.jquery.json b/printThis.jquery.json index c83f0dd..0694577 100644 --- a/printThis.jquery.json +++ b/printThis.jquery.json @@ -1,6 +1,6 @@ { "name": "printThis", - "version": "1.8.0", + "version": "1.9.0", "title": "printThis", "description": "Printing plug-in for jQuery. Print specific page elements, add print options, maintain or add new styling using jQuery.", "author": { diff --git a/printThis.js b/printThis.js index b8b4fb3..6a143b5 100644 --- a/printThis.js +++ b/printThis.js @@ -1,5 +1,5 @@ /* - * printThis v1.8.0 + * printThis v1.9.0 * @desc Printing plug-in for jQuery * @author Jason Day * @@ -28,6 +28,8 @@ * footer: null, * postfix to html * base: false, * preserve the BASE tag, or accept a string for the URL * formValues: true * preserve input/form values + * canvas: false * copy canvas elements (experimental) + * doctypeString: '...' * enter a different doctype for older markup * }); * * Notes: @@ -45,7 +47,7 @@ if (window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)) { // Ugly IE hacks due to IE not inheriting document.domain from parent // checks if document.domain is set by comparing the host name against document.domain - var iframeSrc = "javascript:document.write(\"\")"; + var iframeSrc = "javascript:document.write(\""); + $head.append("