Changing font-family in PDF export (OnDemand)
Asked by Helen Griffith:

Hello!

I am looking for some help on adding a new font to my PDF export. I have found a very helpful page on this so I know it can be done!

[Advanced PDF Export Customisations](https://confluence.atlassian.com/display/AOD/Advanced+PDF+Export+Customisations)

In the Incorporating Other Fonts section it seems to describe exactly what I want to do. However I have to supply a font path that is on the Confluence server. Because I am using Confluence OnDemand, how can I find out what that path might be? And what fonts are available?

Many thanks in advance for any help you can provide,

Helen


Answers:
author: Steffen Heller
body: Hi Helen,

can you upload an attachement with OnDemand ?

If so, this is what I do:

1. Upload a font file to a page as an attachement
2. Go to the attachements and copy the URL of this file
3. Include the font in your CSS with:  
   `@font``-face { `  
   ` ``src: url(URL_of_the_font_file/``name_of_the_file.ttf); `  
   ` ``-fs-pdf-font-embed: embed; `  
   `}`
4. Use this new font as any other font with  
   `font-family: Name of the font*;`

\* The last part, finding the right name of this new font, is tricky. I think that very often my fonts didn't show because the name of the font is not exactly the same as the name of the file. I think the best guess is to double click the file and search for "Font name: abcxyz" and copy this "abcxyz".

comments: author: Helen Griffith
body: Thanks Steffen! I seem to have it working... I am using Cambria and have attached the bold version of the font to the page. I'm not sure how I'd go about using the italic or normal versions though. I tried attaching the Cambria.ttc (font collection) file to the page, but it didn't seem to work. Might try again though... Any ideas?


author: Steffen Heller
body: That is something I haven't understood either. When I search for Cambria I find four different files for bold, bold italic, italic and regular but the "Font name" for all of them is the same, just "Cambria". So I don't know how you can attach the different versions.

Perhaps upload all of them and still try with a name that includes the version:
> `src: url(URL_of_the_font_file/``Cambria regular.ttf);`  
> `src: url(URL_of_the_font_file/``Cambria italic.ttf); `  

Or try to use them with
> `p {`  
> `font-family: Cambria;`  
> `font-weight: bold;`  
> `font-style: italic;`  
> }

I can also only try.

Perhaps you find a solution when you search for "@font-face bold italic regular"...


author: Helen Griffith
body: I have it working like this:

@font-face  
{  
font-family: Cambria;  
src: url(//wiki/download/attachments/40698001/cambriab.ttf);  
font-weight:bold;  
}

@font-face  
{  
font-family: Cambria;  
src: url(//wiki/download/attachments/40698001/cambriai.ttf);  
font-style:italic;  
}

@font-face  
{  
font-family: Cambria;  
src: url(//wiki/download/attachments/40698001/cambriaz.ttf);  
font-weight:bold;  
font-style:italic;  
}  
These @font-faces use the attached fonts in a page that I created for this purpose as you originally suggested.  
Then I use them as follows:  
h1  
{  
font-family: Cambria;  
font-size: 14pt;  
font-weight: bold;  
font-style:italic;  
}  
h2  
{  
font-family: Cambria;  
font-size: 13pt;  
font-weight: bold;  
}  
h3  
{  
font-family: Cambria;  
font-size: 12pt;  
font-style:italic;  
}  
h1 uses the cambriaz.ttf, h2 uses cambriab.ttf and h3 uses cambriai.ttf.  
Hope that helps :)


author: matt chick
body: Brilliant - I have been messing around with this for ages - finally this post helped!

Thanks


author: Thomas Henrion
body: Indeed it works. Just keep in mind that the comment of @Steffen Heller is real.

```
The last part, finding the right name of this new font, is tricky. 
I think that very often my fonts didn't show 
because the name of the font is not exactly the same as the name of the file.
I think the best guess is to double click the file and search for "Font name: abcxyz" and copy this "abcxyz".
```

I ran into the same issue for Open Sans font.

```
@font-face {  font-family: OpenSans;  font-weight: 800;  src: url(//wiki/download/attachments/1000223/OpenSans-ExtraBold.ttf);  -fs-pdf-font-embed: embed;   } 
```

Wasnt working as the use case of @Helen Griffith.

I had to apply the technic listed by @Steffen Heller. Open the font file and copy paste the original name of the font.

```
@font-face {  font-family: 'Open Sans Extrabold';  font-weight: 800;  src: url(//wiki/download/attachments/1000223/OpenSans-ExtraBold.ttf);  -fs-pdf-font-embed: embed;   } 
```

And it now works perfectly


author: Jawann
body: [@Helen Griffith](/t5/user/viewprofilepage/user-id/674249) , [@matt chick](/t5/user/viewprofilepage/user-id/741021) , [@Thomas Henrion](/t5/user/viewprofilepage/user-id/1066415) ,

Howdy, is this still working for all of you?

It suddenly stopped working for me on Tuesday 5/19 in the afternoon (Eastern). I was working on a document and making multiple exports of it that day. They looked perfect on Tuesday morning, but by the evening several of my customizations (including the font) had stopped working. There were no changes to the PDF Stylsheet and it affects all docs, even those that had not been edited for months.

More details here with the couple of other issues I noticed: <https://community.atlassian.com/t5/Confluence-Cloud-discussions/PDF-export-looks-different-no-changes-to-PDF-Stylesheet/td-p/1385072>


author: Thomas Henrion
body: Hello [@Jawann](/t5/user/viewprofilepage/user-id/1232239) I've just checked on an old space I know we exported several times, and the styling still occurs. It might look like the font is not as neat/sharp as we would have accept before, but I cannot confirm.

Good luck !


author: Helen Griffith
body: Hi [@Jawann](/t5/user/viewprofilepage/user-id/1232239)

Gosh, this is going back a long long way in time! I cannot confirm either way if it works. I'd say it's possible that it's broken along with so much else in Confluence Cloud lately! Maybe the PDF stylesheet is not compatible with the new editor even if the pages use the legacy editor?... I am not sure I can help at the moment but I can have a look if my work calms down soon.

Helen


author: Jawann
body: Thanks for the replies [@Thomas Henrion](/t5/user/viewprofilepage/user-id/1066415) and [@Helen Griffith](/t5/user/viewprofilepage/user-id/674249). My admin heard back from support today and apparently there was an issue on their side. They will be deploying a fix "to our instance," so it sounds like probably not a universal issue.

Thanks again.


author: Samiksha Ramgirwar
body: How to change the font family toverdana in exported datatable pdf ?? Please anyone can help me out ???

comments: author: Samiksha Ramgirwar
body: How to change the font family to verdana in exported datatable pdf ?? Please anyone can help me out ???


author: BenoitP
body: Confluence OnDemand can only store one font file/collection (\*.ttf and \*.ttc). You must ask the support to install the desired font for you. Be carefull about the desired font supporting bold, italics and all the required symbols used in confluence.

In my case I wanted DejaVu Font to be my default font. We had a lot of troubles to have all versions packaged in a collection (to show italic, bold and all symbols) but some engineers at Atlassian managed to do it (with FontForge).

So, no workaround. ask the support

comments: author: Helen Griffith
body: Thanks boogaloob---as per my comment to Steffen's response, I kind of have it working. It will probably do for now as the PDF export isn't a regular requirement---I hope!


author: Daniel Sadjadian
body: cool


Tags: font

pdf

stylesheet