From 27af964090603f6dcfe6ad274ee73bfd95c1df64 Mon Sep 17 00:00:00 2001 From: e550443 Date: Thu, 16 Jan 2025 16:20:38 +0100 Subject: [PATCH 1/3] fix: Make it possible to alternate content of header/footer for even/odd pages Fixes #339 --- README.md | 45 ++++++++++++++ src/main/resources/default/dle-pdf-export.css | 61 ++++++++++--------- .../pdf-exporter/html/headerAndFooter.html | 18 +++--- .../converter/PdfConverterTest.java | 16 ++--- 4 files changed, 94 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index b7fe687d..44cb37a7 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,51 @@ In case if both of them specified 'existing_wi_id' has higher priority. (Style package, Stylesheets) there's no `Quick Help` section as their content is self-evident. 4. To change configuration of PDF Exporter extension just edit corresponding section and press `Save` button. +### CSS for booklet layout + +If you export PDF to be printed as a booklet, then you may need to alternate blocks in header/footer depending on the fact if it's even or odd page. +This can be achieved (since version 8.1.0) by CSS modification. Let us give you an example. Find following definition in standard CSS of the extension: + +``` +@page :left { + @top-left { + content: element(top-left); + } + @top-right { + content: element(top-right); + } + @bottom-left { + content: element(bottom-left); + } + @bottom-right { + content: element(bottom-right); + } +} +``` + +...and replace it by this code: + +``` +@page :left { + @top-left { + content: element(top-right); + } + @top-right { + content: element(top-left); + } + @bottom-left { + content: element(bottom-right); + } + @bottom-right { + content: element(bottom-left); + } +} +``` + +As a result blocks in header and footer which in normal case are displayed at right side of the header/footer will be displayed at left side and vice versa. +This is only an example to illustrate an idea, if your use case is different feel free to modify this code according to your requirements. + + ## Usage 1. Open a document in Polarion. diff --git a/src/main/resources/default/dle-pdf-export.css b/src/main/resources/default/dle-pdf-export.css index 604d8e59..fc20f0b9 100644 --- a/src/main/resources/default/dle-pdf-export.css +++ b/src/main/resources/default/dle-pdf-export.css @@ -140,29 +140,41 @@ ul.toc li > a.page-number::after { @page { margin: 120px 60px 90px 80px; border-bottom: 1px solid #aaa; - @top-left { - content: element(top-left); - display: none; - } @top-center { content: element(top-center); - width: 100%; + } + @bottom-center { + content: element(bottom-center); + } +} + +@page :left { + @top-left { + content: element(top-left); } @top-right { content: element(top-right); - display: none; } @bottom-left { content: element(bottom-left); - display: none; } - @bottom-center { - content: element(bottom-center); - width: 100%; + @bottom-right { + content: element(bottom-right); + } +} + +@page :right { + @top-left { + content: element(top-left); + } + @top-right { + content: element(top-right); + } + @bottom-left { + content: element(bottom-left); } @bottom-right { content: element(bottom-right); - display: none; } } @@ -306,30 +318,30 @@ ul.toc li > a.page-number::after { } .header, .footer { - display: inline-block; + display: block; } - .header.top-left { + .header .top-left { position: running(top-left); } - .header.top-center { + .header .top-center { position: running(top-center); } - .header.top-right { + .header .top-right { position: running(top-right); } - .footer.bottom-left { + .footer .bottom-left { position: running(bottom-left); } - .footer.bottom-center { + .footer .bottom-center { position: running(bottom-center); } - .footer.bottom-right { + .footer .bottom-right { position: running(bottom-right); } @@ -868,21 +880,12 @@ li span { line-height: 1em !important; } -.header-footer-wrapper { - display: flex; -} - -.header-footer-left { - flex: 1; -} - .header-footer-center { - max-width: 30%; + /*max-width: 30%;*/ text-align: center; } .header-footer-right { - flex: 1; text-align: right; } @@ -971,4 +974,4 @@ table.polarion-rp-column-layout td { } .polarion-TestRunOverviewWidget-buttonName { padding-top: 20px; -} \ No newline at end of file +} diff --git a/src/main/resources/webapp/pdf-exporter/html/headerAndFooter.html b/src/main/resources/webapp/pdf-exporter/html/headerAndFooter.html index 3422b2a1..a528f0c3 100644 --- a/src/main/resources/webapp/pdf-exporter/html/headerAndFooter.html +++ b/src/main/resources/webapp/pdf-exporter/html/headerAndFooter.html @@ -1,22 +1,22 @@ -