-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Issue: Missing Styles and Improper Font Loading with html2canvas #3198
Comments
Hi |
请问解决了吗 |
Hello, has this issue been resolved? If not, I can assist you in fixing it. price what ever you want to |
If you're using SVGs, make sure you're using embedded fonts that are base64 encoded and aren't linked, for example, add something like this to your chart SVGs: <defs>
<style>
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
src: url(data:font/woff2;base64,...) format('woff2');
unicode-range: ...;
}
</style>
</defs> If you're using Google fonts, you can get the font-face definitions easily here: https://amio.github.io/embedded-google-fonts/ Unfortunately, it's going to severely bloat the size of your SVGs, so you want to make sure you only get the minimum required font-faces. |
I am encountering an issue while using html2canvas in my React project. When I try to capture screenshots of a specific page, some styles are missing, and fonts are not rendering properly in the generated image. The output screenshot doesn't match the original page design. For example, in the generated image, I noticed:
Font styles are incorrect compared to the original page (fonts are not properly loaded).
Certain styles, such as specific colors and visual elements, are either missing or improperly rendered.
I have attached a comparison of the original design and the output generated by html2canvas for reference.
Original Design:

html2canvas Result:

The text was updated successfully, but these errors were encountered: