jsrender/jsreport - How to print a variable an all the pages - printing

I'm using jsreport and using jsrender engine to generate PDF reports.
I want to print some variables on all the pages (but not in the page header or footer), and also a header of a table should appear on all pages. How Can I specify to print something on all pages ?
Thank you.

This could be potentially do-able with thead tag, which by default prints on each page of the long table
<table>
<thead>
<tr><td>Repeated thing here</td></tr>
</thead>
<tbody>
<tr>....</tr>
</tbody>
</table>
Unfortunately this is very buggy in all printing engines, so you may have problems with it, some workarounds are mentioned here https://github.com/ariya/phantomjs/issues/10927

Related

How to force a page break inside an html table when printing (cross-browser)

I have a table and I want to force a page break at a specific <tr> element. So, this is the basic table setup:
<table>
<tbody>
<tr> </tr>
<tr>
<td><p>test text before break</p></td>
</tr>
<tr class="page-break"> </tr>
<tr>
<td><p>test text after break</p></td>
</tr>
<tr> </tr>
</tbody>
</table>
And for css styling:
#media print {
.page-break {
page-break-before: always;
break-before: always;
}
}
Note that page-break-before and page-break-after have apparently been replaced by break-before and break-after (see here). I included both in the css example here to make sure all browsers are compatible (see here and here for browser compatibilities).
Now, the above table and css works in Firefox; does exactly what is expected and places a page break before the <tr> element. BUT, it does nothing in Chrome or Opera (haven't tested other browsers yet).
There have been some discussions on this subject on stackoverflow (see here, for example), but most are outdated and the checked solutions there also don't work in Chrome or Opera. For instance, changing the <tr> element to display: block has no impact (Firefox adds the page break whether the <tr> element is a block or not, and Chrome or Opera do nothing whether or not it is a block).
So I want to start this discussion anew in 2020 to try to find a proper cross-browser solution. So far I haven't been able to find any solution to force a page break within a table that works with Chrome and Opera. Would also like to verify what works in Safari, Edge, etc.

How to open a view form server site and display its link in Asp.net MVC?

I wrote a Web Application. In which the users can make inputs which will be saved
in a database. (with a [HttpPost] function). From these functions I open other Views. My problm is that althought the Views show up without any problem the path in the link stays the same. This is problematic when I want to go back or I want to copy the link... My idea was to somehow display the link per javascript everytime I load a View but that seems to be a very unprofessional way of doing it.
Simple,
<div class="table-outer">
<table width="50%" align="center" border="1">
<tr>
<td>Column1</td>
<td>Column2</td>
<td>Column3</td>
<td>Column4</td>
</tr>
</table>
</div>
.table-outer{width:100%; background:#ddd;padding:20px}
automatically align center
https://jsfiddle.net/kamatchikumar/3u5qwqms/

Find and act on links based on value in a cell with Mechanize in Rails

I am trying to act on links found in a specific row in an HTML table.
The table has a column for a date and a column for city names which act as links. I need to find row with specific date and then cycle through the links found from the next cell on same row one after the another.
I reach the target page with Mechanize from the previous page (link to page is generated at previous page so direct link is not possible) and I am able to select the said table with this:
agent.page.search("//table[#class='calendar']")
But, after that, I am at a loss how to select the correct row based on the date in Date-column and click each of the links in turn (and naturally do stuff before moving on to the next city).
EDIT
I managed to make some progress. I am now able to get contents of correct cell in correct row IF I hardcode the date in. But I can't figure out how to use variable in place of hardcoded date and I also need to find a way to use just the date and not to include weekday as text in there as well.
agent.page.search("//table[#class='calendar']/tbody/tr/td[#class='date']
[text()='wed 27.8.2014']/following-sibling::td[1]/ul/li")
Example HTML below:
<table class="calendar">
<tr>
<th>Date</th>
<th>City</th>
</tr>
<tr class="odd">
<td class="date">thu 28.8.2014</td>
<td class="city">
<ul>
<li>London</li>
<li>Paris</li>
<li>Berlin</li>
</ul>
</td>
</tr>
<tr class="even">
<td class="date">wed 27.8.2014</td>
<td class="city">
<ul>
<li>London</li>
<li>Paris</li>
<li>Berlin</li>
</ul>
</td>
</table>
All help is greatly appreciated!
With further research I was able to find the answer my self. Of great help was this question and answer Nokogiri: How to select nodes by matching text? about partial matching in Nokogiri.
Following snippet is what works for me now and I am able to proceed.
date = Date.new(2014,8,27)
agent.page.search("//table[#class='calendar']/tbody/tr/td[#class='date']
[contains(text(),
\"#{date.strftime("%e.%-m.%Y")}\")]/following-sibling::td[1]/ul/li")

ExactTarget - How to add dynamic user created content in an Email Template

We have an email currently being created in back end code (C#) and sent through the ExactTarget API. I want to move this into a template in ExactTarget so that we don't have to maintain HTML written in StringBuilder() in C#. The issue is the content of the email is determined by what a user inputs. The user fills out a form of what samples they want then an email is sent to a person to fulfill the order.
So an example would be:
<tr>
<td>Product Number</td>
<td>Quantity</td>
</tr>
<tr>
<td>Product Number</td>
<td>Quantity</td>
</tr>
The maximum number of samples that can be ordered is 16. Is there a way to loop through content posted to ExactTarget to create the correct number of rows instead of hard coding 16 rows into the template and half of them being blank.
Please let me know if I need to be more specific about anything
You try just creating a Partial View as below,
#model IEnumerable<CartItems>
<table>
#foreach(var item in Model)
{
<tr>
<td>#item.Number</td>
<td>#item.Quantity</td>
<tr>
}
</table>
Call it from your C# Code as He suggested Here. Render a view as a string
As jordanm mentioned, here is an example in the ExactTarget documentation that covers this. You pass the custom input as XML during your triggered send and parse it / inject it into the HTML with AMPscript.
http://help.exacttarget.com/en/documentation/exacttarget/content/ampscript/using_ampscript_with_the_web_service_api/passing_content_to_a_triggered_send_message_at_send_time/

how can i fetch the tr of this structure in nokogiri of in html response [duplicate]

This question already has answers here:
Parse table using Nokogiri
(3 answers)
Closed 8 years ago.
how can i fetch the tr which mention in code of this structure in nokogiri of in html response
<html>
<body>
<table>
</table>
<table>
<tbody>
<tr>
<td>
<table>
<tr></tr>
<tr><td> wanna this text as output.</td></tr>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
I prefer using the CSS accessors as they're more forgiving. Using your HTML sample, I'd use:
irb(main):026:0> doc.search('table table tr').last.text
" wanna this text as output."
Alternately, the XPATH accessor is:
irb(main):042:0> doc.search('//table//table//tr').last.text
" wanna this text as output."
You're looking for the nested table containing multiple rows. You want the last row.
Be wary whenever you look at the HTML inside a browser and see a <table><tbody> combination. Browsers do a lot of code fix-up, which can result in tags that are not there when you retrieve the HTML directly and pass it into a parser. And, those non-existing tags you see in the browser's output will throw off your CSS or XPath access when you add them in. In particular, <tbody> is a real common problem.
There are multiple ways to access that text, for instance:
html = Nokogiri::HTML my_html_string
row_text = html.at('//table[2]/tbody/tr/td/table/tr[2]').text

Resources