How to change the font in PDF Style Sheet
Asked by jainil trivedi:

Hello,

I want to change the header font of the PDF.

To implement the change:

The stylesheet is implemented into the PDF Space Export Header section. The stylesheet is as below:

```
<table width=100%>
<tr>
<td width=100%>
<img style="float:left" src="download/attachments/7676432/Sterlit%20logo_4.png" alter="header image" />
</td>
<td width=100% >
<!--span style="float:right;font-family: arial;font-size: 16px;font-weight: bold;">User Guide EliteAAA-V6.10.0</span-->
<span style="float:right; font-family: Times New Roman,Calibri,Helvetica,sans-serif;font-size:16px;font-weight:bold;color:black">EliteAAA-V6.10.0</span>
</td>
</tr>
</table
```

In span tag of HTML, there are multiple fonts configured, but it only applies Calibri.

The CSS where body section is implemented is as below:

```
body { 
margin: 0;  
padding: 0;  
font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;  
}  
```

I have questions regarding the same:

1. Is it mandatory to configure all the fonts? Because I have tried by implementing multiple font styles, but it does not consider any font.
2. Why can't we configure single font-style?


Answers:
author: Marta Finazzi
body: Good morning,

Is it possible to view the fonts in Arial family when the document is exported to Word and PDF? The viewing of the fonts is completely different when working on Confluence and when the document is exported to Word and PDF. How can I solve it?

Thanks!

Marta

comments: author: Shannon S
body: Marta,

You have to refer to the font externally in your PDF Export CSS, or upload the font as I let Jainil know about earlier.

Can you let me know if you're having trouble with that?

Regards,  
Shannon


author: Marta Finazzi
body: Hi, Shannon,

Thank you so much for your help. I'm not able to refer the Arial font in my PDF Export CSS. Could you explain me the right steps to do so, please? I'm sure I have to go to "Confluence administration" \> Global PDF Stylesheet \> but then I get lost. Or maybe I'm absolutely wrong...

Thanks in advance!

Regards,

Marta


author: Shannon S
body: Marta,

You can either set a global PDF CSS layout, or space-based.

Have a look at this: [Customize Exports to PDF](https://confluence.atlassian.com/doc/customize-exports-to-pdf-190480945.html)

To reference Arial, you need to use the method in [Advanced PDF Export Customizations](https://confluence.atlassian.com/doc/advanced-pdf-export-customizations-198806890.html?_ga=2.170115936.1181307452.1519116318-306096126.1516091163&_gac=1.93500463.1516875507.CI2P1-XurM8CFUK4GwodnowM2w#AdvancedPDFExportCustomizations-IncorporatingOtherFonts) that I let Jainil know about:

    @font-face { src: url(file:///usr/share/fonts/Arial.ttf); -fs-pdf-font-embed: embed; } .code pre, .preformatted pre, tt, kbd, code, samp { font-family: Consolas, monospace; font-size: 9pt; }

You'll need to link to your specific Arial font on your computer, and this wouldn't work for other users if their computer doesn't have the font in the same location.

Otherwise, you can upload it using the process at [Create a PDF in another language](https://confluence.atlassian.com/doc/create-a-pdf-in-another-language-175473.html) and refer to it in your CSS as ConfluenceInstalledFont.

Regards,

Shannon


author: Marta Finazzi
body: Shannon,

Done! Thank you very much for your help :)

Is it also possible to change the fonts when exporting documents to Word?

Regards,

Marta


author: Shannon S
body: Hi Marta,

You would need to change page CSS for that customization. Have a look at this page for the full explanation:

* [How to customize MS Word exports](https://confluence.atlassian.com/confkb/how-to-customize-ms-word-exports-202780.html)

Let us know if you have any trouble.

Regards,

Shannon


author: jainil trivedi
body: Hi Shannon,

As per the above conversation with Marta, I also want the change in word export.

I followed the document of How to customize MS Word export. But in the document, I have doubt in the path mentioned in the document.

    ...\confluence\WEB-INF\classes\styles\site-css.vm

I am using demo confluence. So I followed the path, but can't found the **Styles**folder. So please help.

Thanks,

Jainil


author: Shannon S
body: Hi Jainil,

I would recommend opening a new question for this since it's no longer relevant to the original question.

Let me know if you have any trouble with that!

Regards,

Shannon


author: Shannon S
body: Hi Jainil,

Can you please clarify exactly what you're looking to see on your page?

From my understanding, you want your header to have a specific font in Confluence, but you mentioned it's only applying one font.

Please provide me with an example of how your header should look vs what it's doing instead. I see the way you've applied your font-family is using a fall-back method, so if the Confluence Installed Font works, then it should stop there and not apply any of the other listed fonts.

Regards,

Shannon

comments: author: jainil trivedi
body: Hi Shannon,

I want a header with the image on the left-hand side and a text on the Right-Hand side. The image is working perfectly. But while applying text, it is considering the default text i.e Times New Roman. I am applying the CSS as

```
<td width=100%>
<span style="font-family: Arial">Testing</span>
</td>
</tr>
</table>
<hr/>
```

It is not working. The text is not displayed in Arial.


author: Shannon S
body: Hi Jainil,

The code you're providing is HTML and not part of a CSS Stylesheet, so can you just confirm exactly where you are putting it?

As for CSS in the PDF export, have a look at [Advanced PDF Export Customizations](https://confluence.atlassian.com/doc/advanced-pdf-export-customizations-198806890.html#AdvancedPDFExportCustomizations-IncorporatingOtherFonts):
> By default, Confluence provides Times New Roman, Helvetica or Courier fonts for use in PDF exports. You can use your own fonts for PDF exports by declaring them in a `@font-face` CSS rule in your PDF Stylesheet.
>
> The following CSS rule example shows how to declare the Consolas font and apply it to some elements for your PDF export:  
> CSS - PDF STYLESHEET
>
>     @font-face { src: url(file:///usr/share/fonts/Consolas.ttf); -fs-pdf-font-embed: embed; } .code pre, .preformatted pre, tt, kbd, code, samp { font-family: Consolas, monospace; font-size: 9pt; }
>
> The font path specified in the CSS must be the path to the font on the Confluence server.

Regards,

Shannon


author: jainil trivedi
body: Hi Shannon,

Thanks for the help. I will try the same.

Regards,

Jainil


author: jainil trivedi
body: Hi Shannon,

Can we change the default fonts from Times New Roman to any other fonts like Georgia or Arial? If Yes then how.

Thanks,

Jainil


author: Shannon S
body: Jainil,

I would simply reference the font in your stylesheet using the method I gave you above, but you can also overwrite the default by uploading a new font:

* [Create a PDF in Another Language](https://confluence.atlassian.com/doc/create-a-pdf-in-another-language-175473.html)

Note this only takes effect in PDF, and this is where you need to reference 'ConfluenceInstalledFont' in your stylesheet.

Regards,

Shannon


author: jainil trivedi
body: Hi Shannon

Thanks for the help. It was really helpful.

Regards,

Jainil


author: Shannon S
body: Jainil,

You're welcome. Let me know if you have any further issues.

Regards,

Shannon