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

I am getting oops, something went wrong! error when i try to create html to Png in Next.js 14 (App router) #464

Open
abhms opened this issue May 7, 2024 · 3 comments
Labels

Comments

@abhms
Copy link

abhms commented May 7, 2024

import { toPng, toJpeg, toBlob, toPixelData, toSvg } from "html-to-image";
const takeSnapImage = () => {
setLoader(true);
const divToCapture = document.getElementById("mainDiv");
console.log(divToCapture, "divvvvvv");

toPng(divToCapture)
  .then(async function (dataUrl) {
         console.log(dataUrl)
  })
  .catch(function (error) {
    console.error("oops, something went wrong!", error);
  });

};
<button
onClick={takeSnapImage}
style={{ color: "black" }}
>
Share Image

when i try to get png or jpg from this version "html-to-image": "^1.11.11" ,i am getting below error
image

Expected Behavior

it should create a png file Url or jpg url it works pretty well with "html-to-image": "^1.9.0" this version
i am using it on server and locally on Linux Mint

Reproduce step:
install version 1.11.11 and then
import all module in component such as
import { toPng, toJpeg, toBlob, toPixelData, toSvg } from "html-to-image";

const takeSnapImage = () => {
setLoader(true);
const divToCapture = document.getElementById("mainDiv");
console.log(divToCapture, "divvvvvv");

toPng(divToCapture)
  .then(async function (dataUrl) {
   console.log(dataUrl)
  })
  .catch(function (error) {
    console.error("oops, something went wrong!", error);
  });

};
this is the error and this version work pretty well "html-to-image": "^1.9.0" but ^1.11.11 give below error,because of it i downgrade the html to image version
image

OS: Linux Mint
Next.js: 14.1.4 (App router with src and typescript)
Google Chrome: 124.0.6367.118

@abhms abhms added the bug label May 7, 2024
@vivcat
Copy link
Contributor

vivcat bot commented May 7, 2024

👋 @abhms

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@abhms
Copy link
Author

abhms commented May 7, 2024

OS: Linux Mint
Next.js: 14.1.4 (App router with src and typescript)
Google Chrome: 124.0.6367.118

@bestmmmz
Copy link

mainDiv下有图片,有跨域问题,html-to-image会报错的

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

No branches or pull requests

2 participants