Hi guys!
Today I stumbled across a solution for a long term problem that we had at my team, so I decided it would be nice to share it here in the community as my first article.
For context, my team uses Confluence as main wiki and document tool. So, from time to time in our projects we have to export pages to send it to people outside our organization. It happens that we use tables a lot, because keeps everything centralized in the page.
Today I had enough! My table was gorgeous in the page, but when I hit export my columns got thinner than a runway model.
I did a little research (https://support.atlassian.com/confluence-cloud/docs/customize-exports-to-pdf/) and found that you can actually manipulate the CSS for the export of the page. Go to Space settings -> Appearance -> PDF stylesheet.
To export the pages in landscape format we can simply add:
@media print { @page { size: A4 landscape; } }
It will apply to all pages in the space.
In my case this was not enough. So I got the page HTML and search for the table element and class to see what I had to add to the stylesheet and end up testing a lot of definitions (many pages were exported, lol).
As a result I got the following CSS applied and it worked fine.
@media print {
@page {
size: A4 landscape;
margin: 20mm;
}
.pm-table-container,
.pm-table-wrapper,
table[data-testid="renderer-table"] {
width: 100% !important; /* Forces full-width table rendering */
max-width: 100% !important;
overflow-x: visible !important;
}
table[data-testid="renderer-table"] {
table-layout: auto !important; /* Allows columns to size based on content */
border-collapse: collapse !important;/* Merges cell borders for cleaner look */
}
col[style],
th[style],
td[style] {
width: auto !important; /* Removes fixed inline column widths */
max-width: none !important; /* Allows cells to expand as needed */
}
th,
td {
white-space: normal !important; /* Enables line wrapping in cells */
word-wrap: break-word !important; /* Breaks long words to prevent overflow */
}
table,
tr,
td,
th {
page-break-inside: avoid; /* Prevents tables or rows from breaking across pages (may cause large white gaps) */
}
body {
overflow-x: visible; /* Ensures the full width of the body is shown */
}
}
If you ever need it, here it is!
Ana Vitória Selista
Atlassian Consultant
3layer
8 accepted answers
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
9 comments