Skip to content

Commit 997756c

Browse files
committed
Fix ligatures and offscreen clipping
1 parent ad97086 commit 997756c

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

html2pdf.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ function html2pdf_makeTemplate(source, optCanvas, info) {
4646
left: 0, right: 0, bottom: 0, top: 0 };
4747
templateCSS = {
4848
position: 'absolute', backgroundColor: 'white', zIndex: 1001,
49-
left: 0, right: 0, top: 0,
49+
left: 0, right: 0, top: 0, height: 'auto',
5050
margin: 'auto', width: optCanvas.width + info.unit };
5151

5252
// Set the overlay and template to be invisible
5353
overlayCSS.overflow = 'hidden';
54-
// overlayCSS.visibility = 'hidden';
55-
overlayCSS.opacity = 0;
54+
// overlayCSS.fontVariantLigatures = 'no-common-ligatures';
55+
overlayCSS.fontFeatureSettings = '"liga" 0';
56+
overlayCSS.opacity = 0;
5657

5758
// 2016-08-30:
5859
// Attempts to increase the canvas *drawing* resolution (dpi isn't solving the problem)
5960
// Transform: scale doesn't work with html2canvas //templateCSS.transform = 'scale(2)';
6061
// Zoom 200% (below) seems to help a bit
61-
templateCSS.zoom = '200%';
62+
//templateCSS.zoom = '200%';
6263

6364
// Create the template div that will be used as a model for the canvas
6465
if (typeof source === 'string') {
@@ -73,6 +74,10 @@ function html2pdf_makeTemplate(source, optCanvas, info) {
7374
setStyle(overlay, overlayCSS);
7475
setStyle(template, templateCSS);
7576

77+
// Set overlay/template classes
78+
overlay.className = 'html2pdf__overlay';
79+
template.className += ' html2pdf__template';
80+
7681
// Attach template and overlay to the document
7782
overlay.appendChild(template);
7883
document.body.appendChild(overlay);
@@ -83,6 +88,8 @@ function html2pdf_makeTemplate(source, optCanvas, info) {
8388
}
8489

8590
function html2pdf_makePDF(canvas, target, optCanvas, optPDF, margin) {
91+
// return document.body.appendChild(canvas);
92+
8693
// Make the PDF and get canvas context
8794
var pdf = new jsPDF(optPDF);
8895
var ctx = canvas.getContext('2d');

0 commit comments

Comments
 (0)