Fix various issues with bold and modern PDF designs

This commit is contained in:
Joshua Dwire 2021-10-05 17:42:41 -04:00
parent fcffafea9d
commit d68040897f
2 changed files with 208 additions and 227 deletions

View File

@ -13,8 +13,13 @@
zoom: 80%; zoom: 80%;
} }
body, html {
margin: 0;
padding: 0;
}
@page { @page {
margin: -0.25cm !important; margin: 0 -5px !important;
size: $page_size $page_layout; size: $page_size $page_layout;
} }
@ -24,20 +29,32 @@
/* page-break-after: always; */ /* page-break-after: always; */
} }
.header-wrapper { #spacer-table > * > tr > td {
padding: 0;
}
#header {
display: grid; display: grid;
grid-template-columns: 1.5fr 1fr 1fr; grid-template-columns: 1.5fr 1fr 1fr;
gap: 20px; gap: 20px;
background-color: #2d2c2a; background-color: #2d2c2a;
padding: 3rem;
color: white; color: white;
min-width: 100%;
line-height: var(--line-height); line-height: var(--line-height);
position: fixed;
top: 0;
}
#header, #header-spacer {
height: 160px;
padding: 3rem;
margin-bottom: 3rem;
} }
.company-logo { .company-logo {
height: 100%; height: 100%;
padding-right: 120px; max-width: 100%;
object-fit: contain;
object-position: left center;
} }
#company-details, #company-details,
@ -46,6 +63,12 @@
flex-direction: column; flex-direction: column;
} }
#company-details,
#company-address,
.logo-container {
max-height: 160px;
}
#client-details { #client-details {
margin: 2rem; margin: 2rem;
display: flex; display: flex;
@ -61,7 +84,6 @@
display: grid; display: grid;
grid-template-columns: 1.5fr 1fr; grid-template-columns: 1.5fr 1fr;
padding-left: 1rem; padding-left: 1rem;
padding-top: 3rem;
} }
.entity-details-wrapper { .entity-details-wrapper {
@ -138,23 +160,23 @@
gap: 80px; gap: 80px;
} }
#table-totals .totals-table-right-side>* { #table-totals .totals-table-right-side > * {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
} }
#table-totals>.totals-table-right-side>*> :nth-child(1) { #table-totals > .totals-table-right-side > * > :nth-child(1) {
text-align: "$dir_text_align"; text-align: "$dir_text_align";
margin-top: .75rem; margin-top: .75rem;
} }
#table-totals>.totals-table-right-side> * > :not([hidden]) ~ :not([hidden]) { #table-totals > .totals-table-right-side > * > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0; --tw-space-y-reverse: 0;
margin-top: calc(.75rem * calc(1 - var(--tw-space-y-reverse))); margin-top: calc(.75rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(.75rem * var(--tw-space-y-reverse)); margin-bottom: calc(.75rem * var(--tw-space-y-reverse));
} }
#table-totals>.totals-table-right-side>*> :nth-child(2) { #table-totals > .totals-table-right-side > * > :nth-child(2) {
text-align: right; text-align: right;
} }
@ -186,51 +208,40 @@
font-size: 1.5rem; font-size: 1.5rem;
} }
.footer-wrapper { #footer {
margin-top: 1rem; margin-top: 1rem;
background-color: #2d2c2a; background-color: #2d2c2a;
height: 160px;
min-width: 100%; min-width: 100%;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
padding: 1rem 3rem;
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
gap: 15px; gap: 15px;
color: white; color: white;
} }
#footer, #footer-spacer {
height: 160px;
padding: 1rem 3rem;
margin-top: 3rem;
}
[data-ref="total_table-footer"] { [data-ref="total_table-footer"] {
padding-top: 0.5rem padding-top: 0.5rem
} }
/** Repeating header & footer styling. */
table { table {
width: 100%; width: 100%;
} }
table.print-content {} table[data-ref="table"] th,
table[data-ref="table"] td {
table.print-content th,
table.print-content td {
padding: .2rem .4rem; padding: .2rem .4rem;
text-align: left; text-align: left;
vertical-align: top; vertical-align: top;
border-top: 1px solid #dee2e6; border-top: 1px solid #dee2e6;
} }
@media print {
.print-footer {
position: fixed;
bottom: 0;
left: 0;
}
.no-print {
display: none
}
}
/** Markdown-specific styles. **/ /** Markdown-specific styles. **/
#product-table h3, #product-table h3,
#task-table h3, #task-table h3,
@ -239,9 +250,9 @@
margin-bottom: 0; margin-bottom: 0;
} }
[data-ref="product_table-product.description-th"] { [data-ref="product_table-product.description-th"] {
width: 23%; width: 23%;
} }
[data-ref="statement-totals"] { [data-ref="statement-totals"] {
margin-top: 1rem; margin-top: 1rem;
@ -253,10 +264,6 @@
white-space: nowrap; white-space: nowrap;
} }
.logo-container {
max-height: 160px;
}
#statement-invoice-table-totals > p { #statement-invoice-table-totals > p {
margin-right: 2rem; margin-right: 2rem;
margin-top: 1rem; margin-top: 1rem;
@ -264,101 +271,96 @@
/** Useful snippets, uncomment to enable. **/ /** Useful snippets, uncomment to enable. **/
/** Hide company logo **/ /** Hide company logo **/
/* .company-logo { display: none } */ /* .company-logo { display: none } */
/* Hide company details */ /* Hide company details */
/* #company-details > * { display: none } */ /* #company-details > * { display: none } */
/* Hide company address */ /* Hide company address */
/* #company-address > * { display: none } */ /* #company-address > * { display: none } */
/* Hide public notes */ /* Hide public notes */
/* [data-ref="total_table-public_notes"] { display: none } */ /* [data-ref="total_table-public_notes"] { display: none } */
/* Hide terms label */ /* Hide terms label */
/* [data-ref="total_table-terms-label"] { display: none } */ /* [data-ref="total_table-terms-label"] { display: none } */
/* Hide totals table */ /* Hide totals table */
/* #table-totals { display: none } */ /* #table-totals { display: none } */
/* Hide totals table left side */ /* Hide totals table left side */
/* #table-totals div:first-child > * { display: none !important } */ /* #table-totals div:first-child > * { display: none !important } */
/* Hide totals table right side */ /* Hide totals table right side */
/* .totals-table-right-side { display: none } */ /* .totals-table-right-side { display: none } */
/** For more info, please check our docs: https://invoiceninja.github.io **/ /** For more info, please check our docs: https://invoiceninja.github.io **/
/** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/ /** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/
</style> </style>
<table> <div id="header">
<!-- Start Header --> <div class="logo-container">
<thead> <img class="company-logo" src="$company.logo" alt="$company.name logo"/>
<tr> </div>
<td> <div id="company-details"></div>
<div class="header-wrapper" id="header"> <div id="company-address"></div>
<div class="logo-container"> </div>
<img class="company-logo" src="$company.logo" alt="$company.name logo"/> <div id="body">
</div> <table id="spacer-table">
<div id="company-details"></div> <thead>
<div id="company-address"></div> <tr>
</div> <td>
</td> <div id="header-spacer"></div>
</tr> </td>
</thead> </tr>
<!-- End Header --> </thead>
<tr> <tbody>
<td id="body"> <tr>
<div class="client-entity-wrapper"> <td>
<div class="client-wrapper-left-side"> <div class="client-entity-wrapper">
<h4 class="entity-label">$entity_label</h4> <div class="client-wrapper-left-side">
<div id="client-details" cellspacing="0"></div> <h4 class="entity-label">$entity_label</h4>
</div> <div id="client-details" cellspacing="0"></div>
</div>
<div class="entity-details-wrapper-right-side"> <div class="entity-details-wrapper-right-side">
<div class="entity-details-wrapper"> <div class="entity-details-wrapper">
<table id="entity-details" dir="$dir"></table> <table id="entity-details" dir="$dir"></table>
</div>
</div> </div>
</div> </div>
</div>
<!-- Start Print Content --> <!-- Start Print Content -->
<table id="product-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="product-table" cellspacing="0" data-ref="table"></table>
<table id="task-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="task-table" cellspacing="0" data-ref="table"></table>
<table id="delivery-note-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="delivery-note-table" cellspacing="0" data-ref="table"></table>
<table id="statement-invoice-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="statement-invoice-table" cellspacing="0" data-ref="table"></table>
<div id="statement-invoice-table-totals" data-ref="statement-totals"></div> <div id="statement-invoice-table-totals" data-ref="statement-totals"></div>
<table id="statement-payment-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="statement-payment-table" cellspacing="0" data-ref="table"></table>
<div id="statement-payment-table-totals" data-ref="statement-totals"></div> <div id="statement-payment-table-totals" data-ref="statement-totals"></div>
<table id="statement-aging-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="statement-aging-table" cellspacing="0" data-ref="table"></table>
<div id="statement-aging-table-totals" data-ref="statement-totals"></div> <div id="statement-aging-table-totals" data-ref="statement-totals"></div>
<!-- End Print Content --> <!-- End Print Content -->
</td> <div id="table-totals" cellspacing="0"></div>
</tr> </td>
<tr> </tr>
<td> </tbody>
<div id="table-totals" cellspacing="0"></div> <tfoot>
</td> <tr>
</tr> <td>
<!-- Start Space For Footer --> <div id="footer-spacer"></div>
<tfoot> </td>
<tr> </tr>
<td style="height: 180px"> </tfoot>
<!-- Leave this empty and don't remove it. This space is where footer placed on print. --> </table>
</td> </div>
</tr> <div id="footer">
</tfoot>
<!-- End Space For Footer -->
</table>
<!-- Start Footer -->
<div class="footer-wrapper print-footer" id="footer">
<div> <div>
<p data-ref="total_table-footer">$entity_footer</p> <p data-ref="total_table-footer">$entity_footer</p>
@ -372,8 +374,8 @@
tables.forEach((tableIdentifier) => { tables.forEach((tableIdentifier) => {
document.getElementById(tableIdentifier).childElementCount === 0 document.getElementById(tableIdentifier).childElementCount === 0
? document.getElementById(tableIdentifier).style.display = 'none' ? document.getElementById(tableIdentifier).style.display = 'none'
: ''; : '';
}); });
}); });
</script> </script>
@ -381,4 +383,3 @@
<div> <!-- #2 column --> </div> <div> <!-- #2 column --> </div>
<div> <!-- #3 column --> </div> <div> <!-- #3 column --> </div>
</div> </div>
<!-- End Footer -->

View File

@ -9,38 +9,45 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
font-size: "7px"; font-size: "7px";
margin: 0;
padding: 0;
zoom: 80%; zoom: 80%;
} }
body, html {
margin: 0;
padding: 0;
}
@page { @page {
margin: -0.22cm; margin: 0 -5px !important;
size: A4 portrait; size: $page_size $page_layout;
} }
p { p {
margin: 0; margin: 0;
padding: 0; padding: 0;
/* page-break-after: always; */
} }
.header-container { #header {
background-color: var(--primary-color); background-color: var(--primary-color);
color: white; color: white;
display: grid; display: grid;
grid-template-columns: 1.5fr 1fr; grid-template-columns: 1.5fr 1fr;
padding: 3rem; position:fixed;
min-width: 100%; top: 0;
height: 160px; }
#header, #header-spacer {
height: 160px;
padding: 3rem;
margin-bottom: 3rem;
} }
.company-name { .company-name {
text-align: left; text-align: left;
} }
.header-container .company-name { #header .company-name {
font-size: 2rem; font-size: 2rem;
} }
#entity-details { #entity-details {
@ -55,7 +62,7 @@
} }
.logo-client-wrapper { .logo-client-wrapper {
margin: 3rem 2rem; margin: 0 2rem 3rem;
display: grid; display: grid;
grid-template-columns: 1.5fr 1fr; grid-template-columns: 1.5fr 1fr;
} }
@ -121,15 +128,18 @@
text-align: right; text-align: right;
} }
.footer-wrapper { #footer {
margin-top: 1rem; background-color: var(--primary-color);
background-color: var(--primary-color); width: 100%;
padding-left: 3rem; position: fixed;
padding-right: 3rem; bottom: 0;
height: 220px; }
width: 100%;
position: fixed;
bottom: 0; #footer, #footer-spacer {
height: 220px;
padding: 1rem 3rem;
margin-top: 1rem;
} }
.footer-content { .footer-content {
@ -222,36 +232,20 @@
} }
[data-ref="total_table-footer"] { [data-ref="total_table-footer"] {
margin-top: 2rem; margin-top: 2rem;
margin-bottom: 2rem; margin-bottom: 2rem;
} }
/** Repeating header & footer styling. */
table { table {
width: 100%; width: 100%;
} }
table.print-content { table[data-ref="table"] th,
} table[data-ref="table"] td {
padding: 0.2rem 0.4rem;
table.print-content th, text-align: left;
table.print-content td { vertical-align: top;
padding: 0.2rem 0.4rem; border-top: 1px solid #dee2e6;
text-align: left;
vertical-align: top;
border-top: 1px solid #dee2e6;
}
@media print {
.print-footer {
position: fixed;
bottom: 0;
left: 0;
}
.no-print {
display: none;
}
} }
/** Markdown-specific styles. **/ /** Markdown-specific styles. **/
@ -306,70 +300,57 @@
/** For more info, please check our docs: https://invoiceninja.github.io **/ /** For more info, please check our docs: https://invoiceninja.github.io **/
/** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/ /** To find out selectors on your own: https://invoiceninja.github.io/docs/custom-fields/#snippets **/
</style> </style>
<div id="header">
<h1 class="company-name">$company.name</h1>
<table id="entity-details" cellspacing="0" dir="$dir"></table>
</div>
<div id="body">
<table id="spacer-table">
<thead>
<tr>
<td>
<div id="header-spacer"></div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="logo-client-wrapper">
<img class="company-logo" src="$company.logo" alt="$company.name logo"/>
<div id="client-details"></div>
</div>
<div class="table-wrapper">
<table id="product-table" cellspacing="0" data-ref="table"></table>
<table> <table id="task-table" cellspacing="0" data-ref="table"></table>
<!-- Start Header -->
<thead>
<tr>
<td>
<div class="header-container" id="header">
<h1 class="company-name">$company.name</h1>
<table id="entity-details" cellspacing="0" dir="$dir"></table>
</div>
</td>
</tr>
</thead>
<!-- End Header -->
<tr>
<td id="body">
<div class="logo-client-wrapper">
<img
class="company-logo"
src="$company.logo"
alt="$company.name logo"
/>
<div id="client-details"></div> <table id="delivery-note-table" cellspacing="0" data-ref="table"></table>
</div>
<!-- Start Print Content --> <table id="statement-invoice-table" cellspacing="0" data-ref="table"></table>
<div class="table-wrapper"> <div id="statement-invoice-table-totals" data-ref="statement-totals"></div>
<table id="product-table" cellspacing="0" class="print-content" data-ref="table"></table>
<table id="task-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="statement-payment-table" cellspacing="0" data-ref="table"></table>
<div id="statement-payment-table-totals" data-ref="statement-totals"></div>
<table id="delivery-note-table" cellspacing="0" class="print-content" data-ref="table"></table> <table id="statement-aging-table" cellspacing="0" data-ref="table"></table>
<div id="statement-aging-table-totals" data-ref="statement-totals"></div>
</div>
<div id="table-totals" cellspacing="0"></div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<div id="footer-spacer"></div>
</td>
</tr>
</tfoot>
</table>
</div>
<table id="statement-invoice-table" cellspacing="0" class="print-content" data-ref="table"></table> <div id="footer">
<div id="statement-invoice-table-totals" data-ref="statement-totals"></div>
<table id="statement-payment-table" cellspacing="0" class="print-content" data-ref="table"></table>
<div id="statement-payment-table-totals" data-ref="statement-totals"></div>
<table id="statement-aging-table" cellspacing="0" class="print-content" data-ref="table"></table>
<div id="statement-aging-table-totals" data-ref="statement-totals"></div>
</div>
<!-- End Print Content -->
</td>
</tr>
<tr>
<td>
<div id="table-totals" cellspacing="0"></div>
</td>
</tr>
<!-- Start Space For Footer -->
<tfoot>
<tr>
<td style="height: 230px">
<!-- Leave this empty and don't remove it. This space is where footer placed on print -->
</td>
</tr>
</tfoot>
<!-- End Space For Footer -->
</table>
<!-- Start Footer -->
<div class="footer-wrapper print-footer" id="footer">
<div class="footer-content"> <div class="footer-content">
<div> <div>
<p data-ref="total_table-footer">$entity_footer</p> <p data-ref="total_table-footer">$entity_footer</p>
@ -384,8 +365,8 @@
tables.forEach((tableIdentifier) => { tables.forEach((tableIdentifier) => {
document.getElementById(tableIdentifier).childElementCount === 0 document.getElementById(tableIdentifier).childElementCount === 0
? document.getElementById(tableIdentifier).style.display = 'none' ? document.getElementById(tableIdentifier).style.display = 'none'
: ''; : '';
}); });
}); });
</script> </script>
@ -396,4 +377,3 @@
</div> </div>
</div> </div>
</div> </div>
<!-- End Footer -->