Commit 3d57b15b authored by Sven Franck's avatar Sven Franck

erp5_corporate_identity: handle edge cases on pdf layouts

parent 78a30a14
......@@ -17,17 +17,19 @@ if parameter == "wkhtmltopdf_rendering_fix":
<script>
(function () {
var table_list = document.body.querySelectorAll("table"),
blockquote_list = document.body.querySelectorAll("table"),
sheet_width_in_px,
div;
if (table_list.length > 0) {
// measure what is the px equivalent for 210mm (A4 210x297mm)
// always measure what is the px equivalent for 210mm (A4 210x297mm)
div = document.createElement("div")
div.style.width = "200mm"; // XXX HARDCODED
document.body.appendChild(div);
sheet_width_in_px = div.clientWidth;
document.body.removeChild(div);
if (table_list.length > 0) {
// Resize a table by reducing th and td font-size,
// to avoid the table to be larger than the sheet width,
// to avoid global fonts to be reduced.
......@@ -46,6 +48,21 @@ if parameter == "wkhtmltopdf_rendering_fix":
});
});
}
// same for other elements
if (blockquote_list.length > 0) {
[].forEach.call(blockquote_list, function (blockquote) {
if (sheet_width_in_px > blockquote.clientWidth) return;
var ratio_percent = Math.floor((sheet_width_in_px / blockquote.clientWidth) * 100);
blockquote.style.width = "100%";
// Select all children and affect the font-size in percent.
// The CSS should not set the font-size on the table instead of th and td
[].forEach.call(blockquote.children, function (e) {
e.setAttribute("style", "font-size: " + ratio_percent + "%");
});
});
}
}());
</script>
"""
......@@ -10,7 +10,7 @@ Return local parameters that require proxy role to access
# pass_flag_site whether called from a web site (no follow-up)
portal_type_valid_template_list = ["Web Site", "Web Section", "Web Page", "Letter"]
portal_type_valid_report_list = ["Project", "Sale Order", "Sale Opportunity", "Requirement Document"]
portal_type_valid_report_list = ["Project", "Sale Order", "Sale Opportunity", "Requirement Document", "Person"]
portal_type = context.getPortalType()
portal_object = context.getPortalObject()
validation_state = ('released', 'released_alive', 'published', 'published_alive',
......@@ -233,7 +233,8 @@ if pass_parameter is not None and pass_source_data is not None:
if pass_parameter == "override_organisation":
return populateOrganisationDict(portal_object.portal_catalog(
portal_type="Organisation",
title=(''.join(["=", str(pass_source_data)]))
#title=(''.join(["=", str(pass_source_data)]))
title=pass_source_data
))
# ----------------------- Sender (Override) ----------------------------------
......
......@@ -420,15 +420,24 @@
.ci-book table td {
border: 1px solid #a1a1a1;
padding: 0 2mm;
}
.ci-book table th {
text-align: center;
}
/* opinionated align for content tables, overwrite in html if required */
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody td,
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody th {
text-align: left;
}
/*
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody tr td:first-child,
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody tr th:first-child {
text-align: right;
}
*/
.ci-book table thead tr th p {
color: black !important;
}
.ci-book p + table td a {
display: block;
}
/* opinionated align for content tables, overwrite in html if required */
.ci-book a + table tbody tr td:first-child,
.ci-book a + table tbody tr th:first-child {
text-align: center;
......@@ -437,7 +446,9 @@
.ci-book a + table tbody tr th:not(:first-child) {
text-align: right;
}
.ci-book p + table td a {
display: block;
}
/* table formatting */
.ci-book table {
border-collapse: collapse;
......@@ -454,6 +465,11 @@
.ci-book table:not(.ci-book-header):not(.ci-book-footer) tbody tr:first-child th {
background-color: #e0e0e0;
font-weight: bold;
text-align: center;
}
.ci-book .ci-book-table tbody tr td,
.ci-book .ci-book-table tbody tr th {
text-align: center;
}
.ci-book table thead tr td,
......@@ -751,9 +767,29 @@ html .ci-book table td p {
}
/* === code boxes === */
.ci-book pre {
text-align: left;
white-space: pre-line;
word-wrap: break-word;
padding: 10px 20px 36px;
background-color: rgb(234,246,246);
/*
white-space: pre;
word-wrap: break-word;
overflow-wrap: break-word;
*/
/*
break after 100 characters - https://stackoverflow.com/a/16756641
max-width: 40em;
max-width: 100ch;
*/
}
.ci-book pre code {
display: block;
background-color: rgb(234,246,246);
}
.ci-book p code,
.ci-book blockquote {
background-color: rgb(234,246,246);
}
/* === special headers === */
......@@ -828,6 +864,7 @@ html .ci-book table td p {
text-indent: 2mm;
}
/* === reports === */
/* should have their own .css/.pdf.css file eventually */
.ci-book .ci-book-table .ci-book-report-cell-left,
.ci-book .ci-book-table td[colspan] {
text-align: left;
......@@ -838,7 +875,10 @@ html .ci-book table td p {
/* === box items === */
/* Project Breakdown/Milestone List */
.ci-book .ci-book-box-offer,
.ci-book div.ci-book-box-offer-milestone {
.ci-book div.ci-book-box-offer-milestone,
/* backcompat */
.ci-document-box-offer,
div.ci-document-box-offer-milestone {
width: 100%;
}
.ci-book .ci-book-box-offer,
......@@ -857,15 +897,25 @@ html .ci-book table td p {
}
.ci-book .ci-book-box-offer b,
.ci-book .ci-book-box-offer-milestone b,
.ci-book .ci-book-box-offer-line b {
.ci-book .ci-book-box-offer-line b,
/* backcompat */
.ci-document-box-offer b,
.ci-document-box-offer-milestone b,
.ci-document-box-offer-line b{
font-weight: bold;
}
.ci-book .ci-book-box-detail {
.ci-book .ci-book-box-detail,
/* backcompat */
.ci-document-box-detail {
table-layout: fixed;
}
.ci-book .ci-book-box-offer,
.ci-book .ci-book-box-offer-line,
.ci-book .ci-book-box-offer-milestone {
.ci-book .ci-book-box-offer-milestone,
/* backcompat */
.ci-document-box-offer,
.ci-document-box-offer-line,
.ci-document-box-offer-milestone {
border: 1px solid #a1a1a1;
padding: 2px;
-webkit-box-sizing: border-box;
......@@ -876,37 +926,54 @@ html .ci-book table td p {
box-shadow: 10px 10px 0 #a1a1a1;
background-color: #fff;
}
.ci-book .ci-book-box-coverage {
.ci-book .ci-book-box-coverage,
/* backcompat */
.ci-document-box-coverage {
display: inline-block;
vertical-align: top;
width: 66%;
}
.ci-book .ci-book-box-location,
.ci-book .ci-book-box-resources,
.ci-book .ci-book-box-leader {
.ci-book-box-location,
.ci-book-box-resources,
.ci-book-box-leader,
/* backcompat */
.ci-document-box-location,
.ci-document-box-resources,
.ci-document-box-leader {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-begin,
.ci-book .ci-book-box-end {
.ci-book .ci-book-box-end,
/* backcompat */
.ci-document-box-begin,
.ci-document-box-end {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-id {
.ci-book .ci-book-box-id,
/* backcompat */
.ci-document-box-id {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-duration {
.ci-book .ci-book-box-duration,
/* backcompat */
.ci-document-box-duration {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-end + .ci-book-box-resources {
.ci-book .ci-book-box-end + .ci-book-box-resources,
/* backcompat */
.ci-document-box-end + .ci-document-box-resources {
margin-left: 20%;
}
.ci-book .ci-book-box-end + .ci-book-box-resources {
.ci-book .ci-book-box-end + .ci-book-box-resources,
/* backcompat */
.ci-document-box-end + .ci-document-box-resources {
margin-left: 20%;
}
......@@ -34,7 +34,7 @@
.ci-book a,
.ci-book li,
.ci-book p,
.ci-book pre code {
.ci-book pre {
font-size: 5.29167mm; /* 15pt; */ /* 20px; */
}
.ci-book .ci-book-img + span,
......@@ -43,7 +43,6 @@
.ci-book table thead td,
.ci-book table tbody td,
.ci-book table tbody td span,
.ci-book table tbody td p,
.ci-book table tbody td li,
.ci-book table tbody td em,
.ci-book table tbody td strong,
......@@ -55,6 +54,9 @@
.ci-book .ci-book-header td:last-child div {
font-size: 4.7625mm; /* 13.5pt; */ /* 18px; */
}
.ci-book table tbody td p {
font-size: inherit;
}
.ci-book .ci-book-header .ci-book-header-subtitle,
.ci-book .ci-book-header .ci-book-header-value,
......@@ -121,6 +123,12 @@
text-align: initial;
}
/* === word breaks (long urls eg) === */
.ci-book p {
overflow-wrap: break-word;
word-wrap: break-word;
}
/* === page breaks === */
.ci-book h1 {
......@@ -418,10 +426,22 @@
.ci-book table th,
.ci-book table td {
border: 1px solid #a1a1a1;
padding: 0 2mm;
text-align: center;
padding: 0 2mm; text-align: center;
}
/* opinionated align for content tables, overwrite in html if required */
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody td,
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody th {
text-align: left;
}
/*
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody tr td:first-child,
.ci-book table:not(.ci-book-header):not(.ci-book-footer):not(.ci-book-table) tbody tr th:first-child {
text-align: left;
}
*/
.ci-book table thead tr th p {
color: black !important;
}
.ci-book a + table tbody tr td:first-child,
.ci-book a + table tbody tr th:first-child {
text-align: center;
......@@ -430,13 +450,9 @@
.ci-book a + table tbody tr th:not(:first-child) {
text-align: right;
}
.ci-book table thead tr th p {
color: black !important;
}
.ci-book p + table td a {
display: block;
}
/* table formatting */
.ci-book table {
border-collapse: collapse;
......@@ -453,6 +469,11 @@
.ci-book table:not(.ci-book-header):not(.ci-book-footer) tbody tr:first-child th {
background-color: #e0e0e0;
font-weight: bold;
text-align: center;
}
.ci-book .ci-book-table tbody tr td,
.ci-book .ci-book-table tbody tr th {
text-align: center;
}
.ci-book table thead tr td,
......@@ -750,16 +771,31 @@ html .ci-book table td p {
}
/* === code boxes === */
.ci-book pre {
text-align: left;
white-space: pre-line;
word-wrap: break-word;
padding: 10px 20px 36px;
background-color: rgb(234,246,246);
/*
white-space: pre;
word-wrap: break-word;
overflow-wrap: break-word;
*/
/*
break after 100 characters - https://stackoverflow.com/a/16756641
max-width: 40em;
max-width: 100ch;
*/
}
.ci-book pre code {
display: block;
background-color: rgb(234,246,246);
}
.ci-book p code,
.ci-book blockquote {
background-color: rgb(234,246,246);
}
/* === special headers === */
/* distribution list */
.ci-book .ci-book thead th {
......@@ -842,7 +878,10 @@ html .ci-book table td p {
/* === box items === */
/* Project Breakdown/Milestone List */
.ci-book .ci-book-box-offer,
.ci-book .ci-book-box-offer-milestone {
.ci-book div.ci-book-box-offer-milestone,
/* backcompat */
.ci-document-box-offer,
div.ci-document-box-offer-milestone {
width: 100%;
}
.ci-book .ci-book-box-offer,
......@@ -861,15 +900,25 @@ html .ci-book table td p {
}
.ci-book .ci-book-box-offer b,
.ci-book .ci-book-box-offer-milestone b,
.ci-book .ci-book-box-offer-line b {
.ci-book .ci-book-box-offer-line b,
/* backcompat */
.ci-document-box-offer b,
.ci-document-box-offer-milestone b,
.ci-document-box-offer-line b{
font-weight: bold;
}
.ci-book .ci-book-box-detail {
.ci-book .ci-book-box-detail,
/* backcompat */
.ci-document-box-detail {
table-layout: fixed;
}
.ci-book .ci-book-box-offer,
.ci-book .ci-book-box-offer-line,
.ci-book .ci-book-box-offer-milestone {
.ci-book .ci-book-box-offer-milestone,
/* backcompat */
.ci-document-box-offer,
.ci-document-box-offer-line,
.ci-document-box-offer-milestone {
border: 1px solid #a1a1a1;
padding: 2px;
-webkit-box-sizing: border-box;
......@@ -880,37 +929,54 @@ html .ci-book table td p {
box-shadow: 10px 10px 0 #a1a1a1;
background-color: #fff;
}
.ci-book .ci-book-box-coverage {
.ci-book .ci-book-box-coverage,
/* backcompat */
.ci-document-box-coverage {
display: inline-block;
vertical-align: top;
width: 66%;
}
.ci-book .ci-book-box-location,
.ci-book .ci-book-box-resources,
.ci-book .ci-book-box-leader {
.ci-book-box-location,
.ci-book-box-resources,
.ci-book-box-leader,
/* backcompat */
.ci-document-box-location,
.ci-document-box-resources,
.ci-document-box-leader {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-begin,
.ci-book .ci-book-box-end {
.ci-book .ci-book-box-end,
/* backcompat */
.ci-document-box-begin,
.ci-document-box-end {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-id {
.ci-book .ci-book-box-id,
/* backcompat */
.ci-document-box-id {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-duration {
.ci-book .ci-book-box-duration,
/* backcompat */
.ci-document-box-duration {
display: inline-block;
vertical-align: top;
width: 33%;
}
.ci-book .ci-book-box-end + .ci-book-box-resources {
.ci-book .ci-book-box-end + .ci-book-box-resources,
/* backcompat */
.ci-document-box-end + .ci-document-box-resources {
margin-left: 20%;
}
.ci-book .ci-book-box-end + .ci-book-box-resources {
.ci-book .ci-book-box-end + .ci-book-box-resources,
/* backcompat */
.ci-document-box-end + .ci-document-box-resources {
margin-left: 20%;
}
......@@ -240,17 +240,23 @@ html .ci-slideshow ol li {
}
/* code */
html .ci-slideshow code {
background-color: #eee;
}
html .ci-slideshow pre {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background-color: #eee;
html .ci-slideshow pre,
html .ci-slideshow-handout pre {
text-align: left;
padding: /*16px;*/ .25em;
white-space: pre-line;
word-wrap: break-word;
padding: 10px 20px 36px;
background-color: rgb(234,246,246);
}
html .ci-slideshow pre code
html .ci-slideshow-handout pre code {
display: block;
background-color: rgb(234,246,246);
}
html .ci-slideshow p code {
background-color: rgb(234,246,246);
}
/* details */
html .ci-slideshow details {
......
......@@ -202,18 +202,21 @@ section {
width: auto;
}
/* code */
html .ci-slideshow code,
html .ci-slideshow-handout code {
background-color: #eee;
}
html .ci-slideshow pre,
html .ci-slideshow-handout pre {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background-color: #eee;
text-align: left;
padding: 16px;
white-space: pre-line;
word-wrap: break-word;
padding: 10px 20px 36px;
background-color: rgb(234,246,246);
}
html .ci-slideshow pre code
html .ci-slideshow-handout pre code {
display: block;
background-color: rgb(234,246,246);
}
html .ci-slideshow p code {
background-color: rgb(234,246,246);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment