Confluence : How can we export PDF in portrait or landscape in the same space ?

Philippe Malera February 21, 2013

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

3 answers

1 accepted

1 vote
Answer accepted
Philippe Malera February 26, 2013

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 !

3 votes
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 21, 2013

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.

Leo Breuss March 3, 2020

2019: Atlassian decided to remove the div macro for your good...

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.
March 3, 2020

Link?

Tobias March 26, 2020

@Steffen Hellerapparently the div-macro got removed. 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?

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.
March 27, 2020

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)

Tobias March 27, 2020

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.

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.
March 27, 2020

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 :first instead:

@page {
size: A4 portrait;
margin: 1cm;
background: red; 
}

@page :first {
size: A4 landscape;
margin: 8cm;
background: green;
}
Meera.Amanullah May 2, 2024

Hi, @Steffen Heller 

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

0 votes
HuseinA
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 21, 2013

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events