Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dom to image giving blank images #459

Open
manishsatschel opened this issue May 11, 2023 · 3 comments
Open

dom to image giving blank images #459

manishsatschel opened this issue May 11, 2023 · 3 comments

Comments

@manishsatschel
Copy link

const nodes = document.querySelectorAll(".pdf-signer-container__signing-node") ?? []

if (nodes) {
nodes.forEach((node) =>{
domToImage.toPng(node).then((resp: any) => {
console.log("resp", resp);
})
} )
}

expected result :- image of each node,

Screenshot 2023-05-11 at 1 05 14 PM

this is one url of the imagees-
Screenshot 2023-05-11 at 1 06 57 PM

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAABCCAYAAAAMuqmTAAAAAXNSR0IArs4c6QAAAcNJREFUeF7t1bERwDAMxLB4/6UzgF2wf6RWI8i8nM9HgMAlcJgQIHALCMOrIPAQEIZnQUAY3gCBJuCP0ZxMjQkIY+zg1m0CwmhOpsYEhDF2cOs2AWE0J1NjAsIYO7h1m4AwmpOpMQFhjB3cuk1AGM3J1JiAMMYObt0mIIzmZGpMQBhjB7duExBGczI1JiCMsYNbtwkIozmZGhMQxtjBrdsEhNGcTI0JCGPs4NZtAsJoTqbGBIQxdnDrNgFhNCdTYwLCGDu4dZuAMJqTqTEBYYwd3LpNQBjNydSYgDDGDm7dJiCM5mRqTEAYYwe3bhMQRnMyNSYgjLGDW7cJCKM5mRoTEMbYwa3bBITRnEyNCQhj7ODWbQLCaE6mxgSEMXZw6zYBYTQnU2MCwhg7uHWbgDCak6kxAWGMHdy6TUAYzcnUmIAwxg5u3SYgjOZkakxAGGMHt24TEEZzMjUmIIyxg1u3CQijOZkaExDG2MGt2wSE0ZxMjQkIY+zg1m0CwmhOpsYEhDF2cOs2AWE0J1NjAsIYO7h1m4AwmpOpMQFhjB3cuk1AGM3J1JiAMMYObt0mIIzmZGpMQBhjB7duExBGczI1JvADjvIAQ58wL9YAAAAASUVORK5CYII=

this is how to image is being printed

@ronghaoZHI
Copy link

Can you present your HTML code? I cannot reproduce your question. @manishsatschel

@manishsatschel
Copy link
Author

Hi @ronghaoZHI this particular issue was fixed there was some issues during selecting that particular node.

however the images inside the dom are not printable in the final created nodes..

@ronghaoZHI
Copy link

@manishsatschel oh..
It will appear when image element inside inline element .
Due to the width or height of inline elements being calculated as zero.
eg: <span> <img src="xxx" /></span> .

bug code: dom-to-image.js#LL557C1-L557C1

function width(node) {
          var leftBorder = px(node, 'border-left-width');
          var rightBorder = px(node, 'border-right-width');
          return node.scrollWidth + leftBorder + rightBorder;
      }

it will work properly being modified like this :

 function width(node) {
           return node.getBoundingClientRect().width || 0;
}
function height(node) {
           return node.getBoundingClientRect().height || 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants