Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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 !

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.

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

@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?

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)

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.

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;
}

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
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,583 views 7 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you