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

Google fonts not working #223

Closed
aravindkesavarapu opened this issue Nov 11, 2023 · 5 comments
Closed

Google fonts not working #223

aravindkesavarapu opened this issue Nov 11, 2023 · 5 comments

Comments

@aravindkesavarapu
Copy link

I have tried multiple ways to add Google fonts to the pdf but nothing worked for me.

Can you help me how to add the fonts style to pdf?

@Clockwerk300
Copy link

Write:
font-family: Inter;
instead of:
font-family: "Inter";

@himwak2001
Copy link

himwak2001 commented Nov 21, 2024

Hi,
You can add any font to the PDF by adding in your java code:

renderer.getFontResolver().addFont("src/main/java/com/app/font/Aptos.ttf", true);

And then, set the font in your HTML/CSS file:

body {
  font-family: Aptos, sans-serif;
}

@asolntsev
Copy link
Contributor

@himwak2001 Thank you for the answer.
Just a small remark: it's better to put such resources to folder src/main/resources instead of src/main/java.

@himwak2001
Copy link

@asolntsev Thankyou for your suggestion.

@DarkTyger
Copy link

You can probably close this issue.

@asolntsev asolntsev self-assigned this Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants