Export part of html i.e. table to pdf with styles - html

Is it possible to export for example table, or ul tags with all children elements to pdf file? (COULD WE USE ONLY FREE OF CHARGE LIBRARIES?)
For example I have the table.
<table>
<tr>
<td class="my-style">
</td>
</tr>
</table>
Is it possible to export this table to pdf with style. I.e. "my-style" has red color.
Thanks in advance :)

We use PDF Sharp and Migradoc to generate PDF files on the fly. Migradoc has good layout and page break controls.
It has table layouts that are pretty easy to understand for most developers.
http://www.pdfsharp.net

You can use iTextSharp lib, this has the ability to decorate display text as you like.
Check this link:
http://www.codeproject.com/KB/graphics/iTextSharpTutorial.aspx

Sergey,
everyone will have their favourite. however, one that I really like and use literally daily, is the http://www.evopdf.com/. allows you to use your existing asp.net views, so really is a no brainer.

Related

Table footer with linked margin note creating large break in text

I am using the tint template in R Markdown for an HTML rendering. I don't think that this issue is specific to R or R Markdown, though. I think the fix can be accomplished with CSS or HTML. Although, I would guess that Dirk, Jon, or JJ, Yihui, or Dave could probably tell me how to fix this properly in R Markdown since they authored or contributed to the development of tint.
How can I modify this to prevent the margin notes from affecting the spacing below the table?
I did try setting the table tag with the styles align: left; and float: left; to see if that would work. Neither impacted the spacing at the bottom.
Here is the table footer with the margin note as HTML script:
<tfoot>
<tr>
<td style="padding: 0; " colspan="100%">
<span style="font-style: italic;">Note.</span> <sup></sup> This is the data dictionary based on the data adapted from CFPB (n.d.)<label for="tufte-sn-3" class="margin-toggle sidenote-number">3</label><input type="checkbox" id="tufte-sn-3"
class="margin-toggle"><span class="sidenote"><span class="sidenote-number">3</span> Consumer Financial Protection Bureau. (n.d.) <em>Consumer complaint database API docs</em> [data set and code book]. Office of Civil Rights. Retrieved
April 28, 2021, from https://cfpb.github.io/api/ccdb/index.html</span> and Rozzi (2021).<label for="tufte-sn-4" class="margin-toggle sidenote-number">4</label><input
type="checkbox" id="tufte-sn-4" class="margin-toggle"><span class="sidenote"><span class="sidenote-number">4</span> Rozzi, G. (2021). <em>Data & functions for working with US zip codes</em>. GitHub. https://github.com/gavinrozzi/zipcodeR/</span>
</td>
</tr>
</tfoot>
I realize it's not all that pretty. While I will likely modify the HTML directly, I didn't write it. It was generated through the use of R Markdown. I typically find that tables can be far less painful, for how often I'm using it, to adjust in the script.
When I render the HTML, there's this huge gap between the table and the next line of text. This is what's happening in the HTML when I run the script:
However, when I use the margin outside of the table, I don't have this problem. (Don't mind the writing; it's definitely not proofread.) If you look, you can see that the second margin note in this image is not impacting the next <p></p>.
Please let me know if there is other information I could provide to get help faster.
It may not be right, but it works. I took the footer off the table and added a block with the footer content. Issue solved. I don't know why I didn't think of that sooner. (sigh)

Expression is not accepted in table element when switching between Source and WYSISYG in CKEditor 4.7

I am making a report template that is required for my school project. Inside the report, I need to display all the cars and their respective details. As you can see from the code below, I am using spring expression language to perform loop on return data and it works as intended.
<div>
<table>
<tbody>
$foreach{car: entity.cars}
<tr>
<td>${car.name}</td>
<td>${car.color}</td>
<td>${car.model}</td>
</tr>
$end{}
</tbody>
</table>
</div>
However, when I switch between Source and WYSISYG, the whole expression will be omitted from the table element and become like this:
<div> $foreach{car: entity.cars} $end{}
<table>
<tbody>
<tr>
<td>${car.name}</td>
<td>${car.color}</td>
<td>${car.model}</td>
</tr>
</tbody>
</table>
</div>
I have read the documentation from CKEditor and found out there's a feature called 'ACF'. It helps us to discards invalid, useless HTML tags and attributes so the editor remains "clean" during runtime.
I already tried
config.allowedContent = true;
I am not particularly sure whether my problem is caused by the 'ACF' feature. If it does, how can I configure it so that the editor will ignore the expression and leave it as it is?
EDIT
I tested the code above with another rich text editor (RTE) out there. Unfortunately, it turns out all of them return the same result. I believe it is illegal to put such an expression between the table elements in an RTE. How should I modify my code so that it is syntactically correct in an RTE?
I just got a workaround for this issue. I noticed the editor will not remove SPEL if I specifically tell it not to do so in the 'config.js' file.
You can achieve this by configuring protectedSource. For more details, please check this link:
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_config.html#cfg-protectedSource

Can we change font color of the data in td tag of html using only CSS

I am creating a custom report that is inserted inside a body of an email content in the form of html. My report generates a table with 3 rows and multiple columns. In 1 of the columns the value is determined dynamically via an environment variable (something like this: $CHILD2_BUILD_RESULT) in Jenkins (either SUCCESS or FAILURE). I want to change the font color of this text placed inside depending on the value. Green if it is SUCCESS , Red if it is FAILURE.
My current code (below) is hard-coded and displays green irrespective of the status.
Is this possible just by using CSS or CSS conditional formatting or handlebars without jquery or javascript
<tr>
<td>Test Result</td>
<td style="color: green;"> <strong>$CHILD1_BUILD_RESULT </strong> </td>
<td style="color: green;"> <strong>$CHILD2_BUILD_RESULT </strong> </td>
</tr>
The fact that the rendered HTML is going into an email is knee-capping you a bit here. There are lots of neat tricks you could do with selectors, but emails require that all CSS be inlined -- which means no selectors.
Your best option is to modify the process that builds the final email output and define two new environment variables: CHILD1_BUILD_RESULT_COLOR and CHILD2_BUILD_RESULT_COLOR. These would contain the string values "green" or "red" (depending on the value of CHILD1_BUILD_RESULT and CHILD2_BUILD_RESULT).
I know you were probably hoping for a more elegant solution, but CSS in email is very limited and has always been a pain point for designers and developers.
I came up with a solution by adding a class to the tag. I named the class as the jenkins environment variable that would store wither SUCCESS or FAILURE then I styles 2 .SUCCESS & .FAILURE as needed inline. This could display the output they I wanted to in email.

Finding the xpath of a certain tag located in an Html Frameset

I am trying to find the xpath of a value in a table located in a frameset in a website to use it on a google spreadsheet for =importxml() to scrape data.
This is the website:
https://eshop.wago.com
<tr>
<td class="text">Connection technology (1) </td>
<td class="text">PUSH WIRE<sup>®</sup> </td>
<td class="text"> </td>
</tr>
For example I want to find the xpath of "Push wire®" right in front of the conncetion technology in the table on the mentioned webpage, when I use the following function in Google spreadsheet it doesn't give any value;
=IMPORTXML(A8, "//*/td[.,='Connection technology (1) ']/following::td[1]")
I think the reason is that the item is located in a frameset and when I try to address the frame with its class it still doesn't work! I am so confused right now. So how can I refer that in "importxml()"?
My answer: you have several problems
1 (out of scope): verify security issues. It is rather usual that the server have not the same behaviour multiple times. It tracks you, authorizes, ...
2 your xpath is not well-formed
this works:
"//*/td['Connection technology (1) ']/following::td[1]"
or this, more robust:
"//*/td[contains(.,'Connection technology (1)')]/following::td[1]"
Hope it helps.

passing angular.js variables to html?

I have an angular app in which there's a table that includes something of the general form:
<tr ng-repeat='d in data'>
<td>{{d.foo}}</td>
</tr>
I'd like to use the value of d.foo (which, for example, could be Bicycle to turn the cell into a link to a website like http://en.wikipedia.org/wiki/Bicycle. I've tried to find an answer to this on SO already but have had no luck; my apologie if I just didn't see it.
Is it possible to do the described task? If so, any pointers or suggestions?
Use:
<td><a ng-href="http://en.wikipedia.org/wiki/{{d.foo}}">{{d.foo}}</a></td>
You can read more here: http://docs.angularjs.org/api/ng.directive:ngHref
;)
Use it in a <a> tag.
For example:
{{d.foo}}