Confluence : How can we export PDF in portrait or landscape in the same space ?
Asked by Philippe Malera:

With Confluence 4.3 we can define a PDF stylesheet at space level, but in the same space we should sometimes export PDF in layout Portrait or Landscape (for large table), that mean two different stylesheets.

But, apparently, we can define only one stylesheet per space.

Is there a way to solve this problem or should we create as many spaces as PDF layout ? (and move documents from one space to another).


Answers:
author: Philippe Malera
body: Thanks for all your propositions, but I was not looking for a "woarkaround", we need an official solution which can be used by about 100 non-technical end-user.

A feature request has been opened for that issue.

<https://jira.atlassian.com/browse/CONF-28251>

Thanks to all of you for your help !


author: Steffen Heller
body: Hi Philippe,

you can achieve exactly this with the help of named pages (just google for it).

I am using it for big tables as follows:

My standard CSS is set for portrait pages with

```
@page {size: 210mm 297mm; /* DinA4 */}
```

When I have a very big table I put it inside a div macro with \<div class="landscape"\>...\</div\>  
In my CSS I define an additional section with

```
div.landscape {page: landscape;}@page landscape {size: A4 landscape; }
```

So whenever there is a table (or anything else) inside a \<div class="landscape"\> the page format will change to "A4 landscape". At the end of the div it will automatically switch back to normal portrait page style.

comments: author: Leo Breuss
body: 2019: Atlassian decided to remove the div macro for your good...


author: Steffen Heller
body: Link?


author: Tobias
body: [@Steffen Heller](/t5/user/viewprofilepage/user-id/781537)apparently the div-macro [got removed](https://confluence.atlassian.com/confcloud/we-re-cleaning-up-the-macro-browser-946028471.html). As far as I can tell you can still use the html macro and simply add the div yourself.

Sadly I was not able to get your solution with the named pages to work. I created a named page and applied it to the first page of the export. That however creates an empty page before it that I can't get rid of.

Is there any chance you could help me?


author: Steffen Heller
body: You have to describe \*exactly\* what you did:

How did you create the named page? Where did you enter the CSS code? Is there other CSS code as well? How did you export? What version of Confluence do you use? Server or Cloud?

My above example works if you...

...enter CSS code at:  
Browse \> Space Admin \> Look and Feel \> PDF Export Stylesheet

...export to PDF with:  
Tools \> Export to PDF

Your description "I created a named page and applied it to the first page of the export" sounds like you did something else.

Depending on your version of Confluence it is also possible that everything is different or does not work at all. All I can say is that my example does still work in my old version (4.3.7, Server)


author: Tobias
body: I edited the stylesheet under "Space Tools -\> Look and Feel -\> PDF Stylesheet". I use the Export function located under "Space Tools -\> Content Tools -\> Export =\> Export as PDF". I am using Confluence version 6.15.9. It is the Server edition which I am hosting myself for testing purposes.

The named page in and of itself is working. The problem is that I defined a named page for my cover page. So it is called with "\<div class='cover-page'\>" in the very first page.

As far as I can tell changing the "@page" automatically creates a pagebreak. That is why I get an empty page at the beginning. For now I just use "@page :blank" and set it to "display: none;" to get rid of it.

I also created a separate post about it [here](https://community.atlassian.com/t5/Confluence-questions/Define-different-page-layouts-for-PDF-export/qaq-p/1333945).


author: Steffen Heller
body: My "solution" was intended for switching back and forth between different page layouts \*within\* a document. And yes, there is always a page break between these pages and when used at the beginning of a document this seems to create an empty page.

But, if I understand you correctly, your intention is different, you want to create \*one\* first page that is different.

For this, you could use [@pagetTeng](/t5/user/viewprofilepage/user-id/2589484) :first instead:

```
@page {size: A4 portrait;margin: 1cm;background: red; }@page :first {size: A4 landscape;margin: 8cm;background: green;}
```


author: Meera.Amanullah
body: Hi, [@Steffen Heller](/t5/user/viewprofilepage/user-id/781537)

I followed the steps you have mentioned for getting the portrait to landscape where required in case of tables. I have got the pages generated in Landscape format, but the table still restricts the width to the size of the portrait page (6.75 in max), As a result, I have the landscape page, but the table doesn't span to the whole page.

Could you please let me know if I'm missing something.

I'm using Confluence Data server, version 8.5.5.

I have the Div macro available in my macrolist.

Thank you


author: HuseinA
body: As far as I know, what you obeserved is an expected behaviour and by design. Indeed, there should be only one PDF stylesheet per space.
> Is there a way to solve this problem or should we create as many spaces as PDF layout ? (and move documents from one space to another).

Instead of keep changing the stylesheet within the same space everytime you need to export in certain style. I suggest to have a Space placeholder of each PDF Stylesheet you would like to have. You might not need to move the pages around Spaces. You can keep the pages at their own home/Space, however, when you need to PDF export them using certain stylesheet, you can then use [include page macro](https://confluence.atlassian.com/display/DOC/Include+Page+Macro) to include that page. After that, you should be able to export it to PDF using the style you wanted it to be.

Not the best and simplest solution, but I think that would do for now.


Tags: addon-com.atlassian.confluence.extra.flyingpdf

export

pdf