From ed68d91620089f5014b80f732cd78f8d4ca4a609 Mon Sep 17 00:00:00 2001 From: Alexander Leyva Date: Wed, 2 Jan 2019 18:50:51 -0300 Subject: [PATCH] Allow wait load css. Allow user manually run the print once the document is ready. --- README.md | 40 ++++++++++++++++++ printThis.js | 116 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 126 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 30e37af..e385f1a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ $('selector').printThis(); ``` ### Advanced Features + +##### Provide options for print ```javascript $('#kitty-one, #kitty-two, #kitty-three').printThis({ importCSS: false, @@ -29,6 +31,27 @@ $('#kitty-one, #kitty-two, #kitty-three').printThis({ }); ``` +##### Manually start the print functionality +```javascript +$('#kitty-one, #kitty-two, #kitty-three').printThis({ + importCSS: false, + loadCSS: "", + header: "

Look at all of my kitties!

" +}, function(doPrint, $doc) { + // handle image errors in the document to print + // ... or do what ever you want with the document already list for print + $doc.find('img').each(function(){ + let img = new Image(); + img.onerror = handleImageError; + img.src = $(this).attr('src'); + }); + + // run the print + doPrint(); +}); +``` + + ### Troubleshooting [Check the printThis wiki for common issues and questions](https://github.com/jasonday/printThis/wiki) @@ -43,6 +66,9 @@ Debug leaves the iframe visible on the page after `printThis` runs, allowing you #### importCSS Copy CSS `` tags to the printThis iframe. On by default. +#### waitLoadCSS +Wait for all css was loaded before start print. + #### importStyle Copy CSS `