Updated: HOW TO Get Page Numbers On PDF Exports
Asked by AB:

So previously, I'd asked the question on *how to get page numbers in PDF exports* so that they appear when you use the \> export PDF feature ++from a page++ in a space.  

The solutions I previously used appeared to stop working after recent updates to Confluence CLOUD in 2018. Other things like: font sizes for an exported PDF similarly stopped working. And posts I found in searching for an answer, unfortunately were all from 4 or 6 years ago, so those solutions didn't work either.   

Here's what I found DID work to get the PDF export to consistently display page numbers on exported PDF's and the body text font-size I wanted. And -- to be clear, I am speaking about exporting to a PDF ++from an actual PAGE++ in a workspace (\**not about 'global pdf' settings*). Screenshot:

![ExportToPdfFromPage.png](https://community.atlassian.com/t5/image/serverpage/image-id/32040iF075EB50EC14166F/image-size/large?v=v2&px=999 "ExportToPdfFromPage.png")

**So to have pages numbers (and other formatting) for my exported PDF, here's the steps that worked for me. A SCREENSHOT is included at end of this post to show this also.**   

**1.** From space settings (the COG icon), click on 'LOOK AND FEEL' and then \> 'PDF STYLESHEET'.

**2.** Paste in your page counter code (and/or other code you wish to apply to the stylesheet). I've included code I used as an example below.   

++For page numbers ONLY++: \*The below example puts the page number on the OUTPUT (exported) PDF to 'bottom right' side of the page. You could change that to @bottom-left for example. Also note: you do NOT have to include font-family, font-size, or padding... you can change or delete those attributes your preference. But I left it in here for example purposes.

```
@page
?{ 

? ?@bottom-right?{
? ? content: "PAGE" counter(page); /* Page + number counter to appear bottom right of page */
? ? font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
? ? font-size: 8pt;
? ? padding-bottom: 3em;
? ? }

}
```

++For other styles like: adjust body margin, add page number, and specify 'body text' font size on the output PDF++ : \*The below will adjust the printable pdf to have specific margins, a larger body font size than the page number in the footer, and changed the body font line-height. Again all these you can change or delete to your preference, but I'm including it as example:   

```
@page
{ margin: 0.7in;
 
 @bottom-left
 {
 content: "SOME TEXT HERE"; /* Content to appear bottom left side of page */
 font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
 font-size: 8pt;
 padding-bottom: 3em;
 }
 @bottom-right
 {
 content: "PAGE" counter(page); /* Page and page NUMBER counter to appear bottom right side of page */
 font-family: ConfluenceInstalledFont, Helvetica, Arial, sans-serif;
 font-size: 8pt;
 padding-bottom: 3em;
 }
 
}

/* Body font pdf export */
body,p,li,td,table,tr,.bodytext,.stepfield 
{
 font-size: 10pt; 
 line-height: 1.25 !important;
}
```

**Here's a screenshot of how this looks in the PDF Stylesheet pane to illustrate:**

**![SpaceSettingsPDFStyleExample.png](https://community.atlassian.com/t5/image/serverpage/image-id/32043iA16056AFA1A9B73D/image-size/large?v=v2&px=999 "SpaceSettingsPDFStyleExample.png")**

**\*\*\*End note:** When combining the style for the PDF @page and body font size, it only worked when body {} was at the END of the stylesheet and not before. This is why I have body font separately at end and after the @page call.

As of right now, the above is what worked for me (*again I am using CLOUD version so there's no direct server access to custom code exactly which others may be able to do in a self hosted instance* ).... Additionally: If you have applied any PDF style settings in GLOBAL settings (from Atlassian \> App \> Confluence) that is a different pathway than the one I outline above. What I did here was apply settings directly from within a SPACE (not global). Any global settings you apply may impact or otherwise 'override' what you put in space settings. Mentioning ....  

Anyway, I hope this may help someone else.

Thanks!


Answers:
author: AB
body: I originally posted the question on this, but found a solution and amended the post to reflect the solution I found. Hope it helps others too. Thanks.


author: Micheal Planck
body: I do not understand this. The documentation clearly says: "Changes to the PDF layout only apply to space exports, not to single page exports." Meaning that nothing in the space setting css style sheet matters.

But my problem is the opposite. I would like \*not\* to have a toc and page numbers. There is a tick box on the Export Space screen that says "\[ \] Include Page Numbers." This tick box does nothing; there are always page numbers when I export a single page from Export Space, along with a toc.

Can you imagine having a job where your job was to put options on a screen, but not actually do the options? I mean, why not add "\[ \] Win the lottery" or "\[ \] Fly to the moon" while you are at it. I am sure those options would be wildly popular with users.

Meanwhile, I can get the content to format in landscape mode... but the resulting PDF is still in portrait mode and hence cuts off the content.


author: Meg Holbrook
body: Good morning!

I don't see a way to add page numbers prior to export, but I did find information on adding page numbers after the file has been exported. The instructions below are from adobe, but I'm certain that other PDF handlers have similar functionality:

<https://helpx.adobe.com/acrobat/using/add-headers-footers-pdfs.html>

comments: author: AB
body: Hi Meg -- amazingly after I posted this (after trying so many ideas previously posted) -- I did find a way. I will update my original post with what I did to accomplish this which may hopefully be of use to others. It is a similar thing to others prior posts, but I think that with the more recent changes to CLOUD version, the format of things changed slightly (which I will explain when I update the post)....

<br />

Thanks much for your feedback and help!

PS: I previously used the 'reply' feature but it did not update here (at least not yet) -- so if you see duplicate reply to this, that's why. Thanks again!


author: Meg Holbrook
body: Glad to hear it!


author: AB
body: Hi again Meg! Ok I updated my post to describe the solution that worked for me. I hope it helps others (for now anyway).

Thanks for your reply back!


author: Meg Holbrook
body: I hadn't remembered the stylesheet until you mentioned it, awesome!


Tags: confluence-cloud

export

number

page

pdf