Changing font-family in PDF export (OnDemand)

Helen Griffith February 5, 2014

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

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

3 answers

1 accepted

3 votes
Answer accepted
Steffen Heller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2014

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".

Helen Griffith February 10, 2014

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?

Steffen Heller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 10, 2014

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"...

Helen Griffith February 11, 2014

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 :)
Like Jawann likes this
matt chick January 25, 2016

Brilliant - I have been messing around with this for ages - finally this post helped!

Thanks

Thomas Henrion June 2, 2017

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

Like Jawann likes this
Jawann May 27, 2020

@Helen Griffith , @matt chick , @Thomas Henrion ,

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

Thomas Henrion May 28, 2020

Hello @Jawann 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 !

Helen Griffith May 31, 2020

Hi @Jawann

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

Jawann June 2, 2020

Thanks for the replies @Thomas Henrion and @Helen Griffith. 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.

0 votes
Samiksha Ramgirwar March 11, 2021

How to change the font family toverdana in exported datatable pdf ?? Please anyone can help me out ???

Samiksha Ramgirwar March 11, 2021

How to change the font family to  verdana in exported datatable pdf ?? Please anyone can help me out ???

0 votes
BenoitP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2014

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

Helen Griffith February 10, 2014

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!

Daniel Sadjadian April 21, 2015

cool

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events