MvcRazorToPdf align content to bottom of page - asp.net-mvc

I am trying to get a footer in a generated pdf file. I am using this library
https://github.com/andyhutch77/MvcRazorToPdf
Is there any way to get some of my content to the bottom of the page? Unfortunately pdf does not respond to position:absolute; bottom:0px; or margin-bottom.
The page shows an unknown amount of records on the page, so I cannot do it statically.

I found a way to solve this problem. It's not very neat, but I doubt there are other ways since MvcRazorToPdf does not support the margin and position styles.
<table id="wrapper" style="height:100%;">
<tr>
<td valign="top">
Put your site content here.
</td>
</tr>
<tr>
<td valign="bottom">
Put your footer here.
</td>
</tr>
</table>

Related

Why the content of my table is still visible when the condition is not set in Thymeleaf?

I want that my table is only visible if the size of the list opleidingen is not null.
But altough the list is empty, he still shows the header of the table and the icons. What do I do wrong?
Thankyou
<table th:if="${opleidingen.size() != 0}">
<theader>
<tr>
<th>Code</th>
<th>Titel</th>
<th>Thema</th>
<th>Delete</th>
<th>Pas Aan</th>
</tr>
</theader>
<tbody>
<tr th:each="opleiding: ${opleidingen}">
<td><span th:text="${opleiding.getCode()}"/></th>
<td><span th:text="${opleiding.getTitel()}"/></th>
<td><span th:text="${opleiding.getThema()}"/></th>
<td><img src="../static/Delete.gif"/></th>
<td><img src="../static/Edit.gif"/></th>
</tr>
</tbody>
</table>
Keeps being visible: the header of the table theader tekst and the images. Why, since there are no items to be shown, the whole table shouldn't be shown?
You need to have Thymeleaf render the template, otherwise, the Thymeleaf specific attributes will not do anything.

Puppeteere/Chromium pdf printing ignores css page-breaks in tables

I was browsing the last hours to find a solution for my problem with latest puppeteer (2.0.0) / chromium 78.0.x to get our printing system working. We allow to setup page breaks in tables, which worked find in PhantomJS renderer, but not in the puppeteer/chromium solution.
Beside many little difference in global css and printing PDF header/footer the printing of tables was the last problem (hopefully).
It turns out that the "page-break-before: always" is simply ignored.
Example:
<table>
<thead> ... </thead>
<tbody> ...
<tr style="page-break-before: always;"> ...should be on next page ... </tr>
</tbody>
</table>
Some of the Chrome forum articles point out, this has been solved.
So the question is what is causing the problem.
Regards,
Andre
PS) Later we found now: put a "display: block" on all tags of the table solves the problem. Maybe that helps someone. Any comments on that?
<table style="display: block;">
<thead style="display: block;"> ... </thead>
<tbody style="display: block;"> ...
<tr style="display: block; page-break-before: always;"> ...is now on the next page ... </tr>
</tbody>
</table>
Bad news for the solution we provided above. This destroys the feature of having table headers on each page.
setup 1)
Setting "display: block;" for the thead will disable the feature of having the table header on each page.
==> no page break
setup 2)
Set the thead to "display: table-header-group;" and tbody to "table-row-group" then the chrome will ignore the page-breaks.
==> no table headers on each page
setup 3) Having the thead: "display: table-header-group;" and the tbody: "display: block" is destroying the column structure. The body will be rendered only on the first column.
==> Destroys the table. the body is just in the first column
Here comes our hack to solve the problem. we use setup 3, with this:
- we build a table with just one column
- the column contains a table with all columns we really want to render
- the column widths are set to fix values (that was anyway the case in our rendering system)
<table>
<thead>
<tr>
<td> <table> .... the header of the real table </table> </td>
</tr>
</thead>
<tbody style="display:block;">
<tr>
<td>
<table> .... one row of the real table </table>
<td>
</tr>
<tr>
<td>
<table> .... another row of the real table </table>
<td>
</tr>
</tbody>
</table>

Tables and div elements are not centred in reveal.js

If I add the following slide into the default presentation provided by reveal.js, then the table is not centred.
<section>
<p>This is centred</p>
<table>
<tr>
<td>This</td>
<td>is</td>
<td>not</td>
</tr>
</table>
</section>
I can fix it by adding in padding, but this then becomes dependent on the screen size, and I am worried that when I go to present the screen will be a different size. There must be a better way?
According to this and my testing, if you add the reveal class to your table, the newest reveal.js should center it.
<section>
<p>This is centred</p>
<table class="reveal">
<tr>
<td>This</td>
<td>is</td>
<td>not</td>
</tr>
</table>
</section>

Calculating total from a html table using Angular

I am really new with Angular and just finished the tutorial and my contact-list app. I would like to perform some simple calculations with rails generated html table using AngularJS on the client-side.
My table looks like this
<table>
<thead>
<tr>
<th>Group</th>
<th>Current</th>
<th>Previous</th>
<th>Difference %</th>
</tr>
</thead>
<tbody>
<tr>
<td>Name</td>
<td>10</td>
<td>20</td>
<td>100%</td> //Want to use Angular
</tr>
</tbody>
<tr>
<td>Total:</td>
<td>10</td> //Want to use Angular
<td>20</td> //Want to use Angular
</tr>
</table>
I could write it with simple Javascript, however with time I would like these numbers to change styles, depending on the result, draw graphs, etc.
Please point me into the right direction! Thank you!

Does HTML5 ban th cells from tbody?

I have the following markup as a part of a Razor view:
<table>
<caption>Presidents</caption>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Born</th>
<th scope="col">Died</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Washington</th>
<td>1732</td>
<td>1799</td>
</tr>
<!-- etc -->
</tbody>
</table>
With the "target schema for validation" set to HTML5, Visual Studio complains thusly:
Warning 1 Validation (HTML5): Element 'th' must not be nested within element 'tbody tfoot'.
Is this really true? If so, could someone link to the spec?
My understanding was that using <th> for row headers was not just legal but encouraged. It certainly seems fairly common, I could link dozens of tutorials explaining (seemingly sensibly) that it helps with accessibility.
Is this a VS bug? A real change coming with HTML5 (a good one? a bad one?)? What's the story?
My understanding was that using <th> for row headers was not just legal but encouraged
As far as I know, this was always legal in HTML 4 (and possibly its predecessors), and hasn't changed in HTML5.
W3C's HTML5 validator, while still experimental, reports no warnings or errors. Then again, I'm sure the HTML5 validation Visual Studio is using is experimental as well since HTML5 itself hasn't yet been finalized.
The HTML5 spec on marking up tabular data, specifically section 4.9.13, shows the use of <th> within <tbody> and <tfoot> to scope row data:
<table>
<thead>
<tr>
<th>
<th>2008
<th>2007
<th>2006
<tbody>
<tr>
<th>Net sales
<td>$ 32,479
<td>$ 24,006
<td>$ 19,315
<tr>
<th>Cost of sales
<td> 21,334
<td> 15,852
<td> 13,717
<tbody>
<tr>
<th>Gross margin
<td>$ 11,145
<td>$ 8,154
<td>$ 5,598
<tfoot>
<tr>
<th>Gross margin percentage
<td>34.3%
<td>34.0%
<td>29.0%
</table>
So it's perfectly legitimate to have <th> elements inside <tr> elements inside either a <tbody> or <tfoot>. As it should be anyway, since table headings aren't just found on table headers.
The HTML5 spec only requires that it be inside a tr, and the spec actually includes an example with a th nested inside a tbody.
Generally a TH in a THEAD will have a scope value of "col" while a TH in a TBODY will have a scope value of "row".

Resources