I was going to write as a comment for not having a test environment, but it’s getting great so it goes as a response even without being able to test...
First on the fonts, there’s something called Web Safe Font, in summary your user needs to have the source installed in the Operating System to see the source correctly. See the image below to better understand. A reference source https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Fundamentals#Web_safe_fonts
Then there are variations of the name for the same font-family
, so save yourself and include the two variations for example as below:
font-family: "Comic Sans MS", "Comic Sans", cursive;
Then I noticed that you didn’t put the Quote character " "
in the font name and this is not within the correct CSS writing format, so do not use "
and use double quotes only "
or single quotes '
. In the case how you are using style right in the tag the ideal would be to leave so " ' ' "
or the other way around ' " " '
style="font-family: 'Comic Sans MS', 'Comic Sans', cursive;"
About the background
img and color
In print you can see in these two answers that I gave some alternatives to do this! But basically for image you can use inside the @print
one display:block
on the tag <img>
, for img
as background-image
does not work, and for color you can use box-shadow
with the attribute inset
to play the "inside" color of the element.
Follow the other answers I’ve done about color and image at the time of printing. I recommend that you read the full answers, here is only the summary...
For image:
Apply watermark without affecting text
Print page with Background
.imagem {
display: none;
}
@media print {
.imagem {
display: block;
}
}
<div class="imagem">
<img src="cancelado.png" alt="">
</div>
Color
Print HTML page keeping the page CSS
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
table thead tr th {
background: greenyellow; /* cor antes da impressão */
}
@media print{
table thead tr th{
box-shadow: 0 0 0 1000px red inset; /* cor para impressão */
}
}
<div class="container">
<table border="1">
<thead>
<tr>
<th>Item 1</th>
<th>Item 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Texto 1</td>
<td>Texto2</td>
</tr>
</tbody>
</table>
</div>
A tip
Check the documentation of Jboss Seam Pdf if it has like you automatically embedar
to font-family
, here on the Adobe website has information about this: https://helpx.adobe.com/acrobat/using/pdf-fonts.html
About the background color/image
you can see in the documentation if you can print the PDF as an image https://helpx.adobe.com/acrobat/kb/quick-fix-print-pdf-image.html or if you have the option to bring by default the option of "Background Graphics" as mentioned in the comment.
Hello Dear, I don’t know if it’s your case because you’re talking about pdf, but I’ve seen a problem like this in HTML, and the solution was to change the css
color-adjust
something like:*{ color-adjust: exact; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
– Icaro Martins
Related: How to print HTML background colors with CSS
– Icaro Martins
Thanks @Icaromartins, I will add the style in my text. Once I have results, I will return.
– Gustavo Cinque
It didn’t work, @Icaromartins
– Gustavo Cinque
The component you are using to generate the PDF is the iText? If I’m not mistaken the color adjustment of a paragraph should be done within the environment Java for the iText does not support background setting in paragraph from HTML/CSS/Javascript.
– Augusto Vasques
No, it’s Jboss Seam.
– Gustavo Cinque
Is that https://docs.jboss.org/seam/2.3.1.Final/reference/html/itext.html ? If it is, the component used is iText.
– Augusto Vasques
It seems to be the same, but I have no way to make any configuration in code, because the background-color should be interpreted inside p:html. As far as I knew it had no relation to the framework you talked about, I’ve always seen iText working the pdf within the code.
– Gustavo Cinque
I get your point. Well, this solves the situation, knowing that it is a problem of the framework itself. Thank you very much Augusto. Please create an answer with this information, as if the correction suggested by hugocsl does not work, I will accept your.
– Gustavo Cinque
I’m not gonna give you an answer because I haven’t used it for a long time Java and many things I no longer remember, but if I am not mistaken this limitation can be circumvented by placing the paragraph within a
<div>
or inside a cell of a table, instead of trying to color the background of the paragraph<div>
or<td>
depending on which approach to use. Test as not sure.– Augusto Vasques