html2canvas ignoreElements test

by Erik Koopmans

HTML

<script src="https://rawgit.com/eKoopmans/html2pdf/master/dist/html2pdf.bundle.min.js"></script>
<script src="https://github.com/niklasvh/html2canvas/releases/download/v1.0.0-alpha.12/html2canvas.min.js"></script>
<button id="generate">Create PDF</button>
<button id="generateCanvas">Create Canvas</button>

<div id="element-to-print">
  Element to print.
  <h1>
    Hello!
  </h1>
</div>

CSS

#element-to-print {
  background-color: green;
  height: 100px;
}

JavaScript

document.getElementById('generate').onclick = function () {
	// Your html2pdf code here.
	var element = document.getElementById('element-to-print');
	html2pdf(element);
};

document.getElementById('generateCanvas').onclick = function () {
	var element = document.getElementById('element-to-print');
	html2canvas(element, {
  	// ignoreElements: function (el) {return el.tagName.toLowerCase() === 'h1';}
  	ignoreElements: function (el) {}
  }).then(function (canvas) {
  	document.body.appendChild(canvas);
  });
};