Skip to content

Commit

Permalink
修复高度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hzsrc committed Jan 13, 2025
1 parent d71ce44 commit da1953d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-to-image-big",
"version": "1.11.12",
"version": "1.11.13",
"description": "Generates an image from a DOM node using HTML5 canvas and SVG. Support big html page.",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ export async function nodeToDataURL(
const svg = document.createElementNS(xmlns, 'svg')
const foreignObject = document.createElementNS(xmlns, 'foreignObject')
// add a tail for check ending
const heightWithTail = height + TailHeight * 2
let heightWithTail = height
if (opt.checkTail) heightWithTail += TailHeight * 2
// fix: if ratio=2 and style.border='1px', in html it is actually rendered to 1px, but in <img src="svg" alt="i"> it is rendered to 2px. Then height is different and the bottom 1px is lost, 10 nodes will lost 10px.
const ratio = getPixelRatio()
svg.setAttribute('width', `${width / ratio}`)
Expand Down

0 comments on commit da1953d

Please sign in to comment.