-
Notifications
You must be signed in to change notification settings - Fork 364
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
Can't use own fonts #183
Comments
Same problem... how can we solve this? |
I found out that it does this mainly for. For example, if the border, height, etc are set here. But if I give the border directly to the style in the tag, so it works... |
My problem is that I define the font in css like this:
and a little bit later I call the font like this
but it doesn't use the font in the generated pdf. |
Hi @Xiirs Thanks for providing a stack trace. The trace suggests you are using form input controls. If possible I would like a minimal example with form controls that reproduces the bug you are seeing, as I can't manage to reproduce. However, for the time being, can I suggest you make sure that input controls are not using a custom font. Example below: <html>
<head>
<style>
@font-face {
src: url(./fonts/JustAnotherHand.ttf);
font-family: 'handwriting';
}
* {
font-family: 'handwriting';
}
/* Put this last to make sure controls use a built-in font. */
input, select {
font-family: serif !important;
}
</style>
</head>
<body>
<h1>Form controls with custom font example</h1>
Some text in handwriting font.
<form>
<input name="text-input" type="text" value="Some text in normal font!"/>
</form>
</body>
</html> |
Hi @kuhlware I think your issue is different. Perhaps the font is not path is not resolving correctly relative to the provided or implicit base url? Can you provide a minimal example with html and builder code? Thanks. |
It crash with this. Css: input{border: 1px black solid; width: 100%; height: 30px; font-size:18px;} html: |
Hi @Xiirs I was able to reproduce! It appears that the built-in stylesheet uses an
|
Thanks. I am gonna try it. |
Hi,
I tried to add custom fonts, but always with the same error. Can you advise what I am doing wrong or whether it is an internal error?
java.lang.NullPointerException
at com.openhtmltopdf.pdfboxout.PdfBoxFontResolver.resolveFont(PdfBoxFontResolver.java:70)
at com.openhtmltopdf.layout.SharedContext.getFont(SharedContext.java:391)
at com.openhtmltopdf.pdfboxout.PdfBoxOutputDevice.processControls(PdfBoxOutputDevice.java:316)
at com.openhtmltopdf.pdfboxout.PdfBoxOutputDevice.finish(PdfBoxOutputDevice.java:1000)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.writePDF(PdfBoxRenderer.java:607)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:546)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:485)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:481)
at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:86)
at cz.codeberry.oneclick.example.SimpleUsage.exportToPdfBox(SimpleUsage.java:30)
at cz.codeberry.oneclick.example.SimpleUsage.main(SimpleUsage.java:17)
My CSS:
@font-face {
src: url("./OpenSans.ttf");
font-family: "Open Sans Condensed";
font-weight: 700;
}
h1 {
font-family: "Open Sans Condensed", "Arial Narrow", Arial, sans-serif;
}
I tried I add the font directly to the builder, but also unsuccessfully:
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.withFile(file);
builder.useFont(new File("./OpenSans.ttf"), "Open Sans Condensed");
builder.toStream(os);
builder.run();
The text was updated successfully, but these errors were encountered: