xhtml2pdf does not show image always - image

I use xhmtl2pd tool to convert html to pdf. Here is a piece of my html
<tr>
<td style="width:10px;vertical-align:top">• </td>
<td style="padding:0 0 5px 0;width:200px;display:inline-block">
blah blah <br/>
<img src="images/little-gray-arrow.png" height="10" width="11" alt="blah" />
</td>
</tr>
The bizarre thing is if I remove the br tag then the image of little-gray-arrow.png never shows up. Put the br tag back, the image shows up in the "next" line.
I have tried with all options, padding, margin, and none works.
I also try to inline-displaying an image between text, and the image clock.png bottom half always get cut off, regardless what I tried.
<tr>
<td style="width:10px;vertical-align:top">• </td>
<td style="padding:0 0 5px 0;width:200px;">
Wait
<img src="images/clock.png" height="20" width="20" alt="20" />
minutes
</td>
</tr>
Does anyone know how to solve this problem and it is just the way xhmtl2pdf is.
Can the xhtml2pdf display image inline?
Thanks

Dont use absolute paths in url or src. Use fullpath like https://abcd.com/.../image.png . It worked for me

If you need render image format like GIF or PNG, you should install PIL library. The Python Imaging Library (PIL) is requred by ReportLab for handling PNG/GIF image.
Refer: Output image to pdf with xhtml2pdf

Related

SASS: Applying style based on presence of child element type

I have a collection of tables nested within each other and background colors that are applied to each <td> in each row. I would ideally like to set the background as transparent on those <td> elements that themselves contain a child table, but I cannot identify how I'd specify this in SASS.
For example, I might have something like the following:
<table>
<tbody>
<tr>
<th>Data Point</th>
<!-- This should be styled with a red background -->
<td>0.025</td>
</tr>
<tr>
<th>Data Point</th>
<!-- This should be styled with a transparent background since it contains a table -->
<td>
<table>
<tbody>
<tr>
<th>Sub-point</th>
<!-- This should styled with a red background -->
<td>0.75</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
I can just have a naive selector like the following to apply the background on my td elements:
td {
background: #ff0000;
}
But it's not clear how I might then modify this (without adding another class to everything) to set the background to transparent if the <td> contains a <table>.
I'm ideally looking to avoid all use of JavaScript and only handle this through SASS.
Attempt #1
At first, the pseudo-class :has() looked promising, but the guidance in this issue suggests it cannot be used in this scenario.
Attempt #2
I could just specify a new class on the <td> containing the nested element and override the background style from there, but this isn't as clean an approach. I'll reserve this as the fallback solution, but a selector-based approach would be preferred.
Is this even possible?

Xpath extract text from a form

<td nowrap>Source name</td>
<td style="text-align: justify">Fresh postmortem eye<br>
I need to extract the text "Fresh postmortem eye" that comes after "Source name" on a form. I tried this:
//Source name/following-sibling::text()[1]
and didn't get anything. I'm hacking together a webscraper.
Try this one:
//td[.="Source name"]/following-sibling::td[1]/text()

Nokogiri stopped searching for sub tags

I was writing my ruby (2.0) script which reads a web page & it was working fine. Then I installed ruby 2.2 and suddenly my nokogiri stopped searching sub tags but not all. It still finds some sub tag and some aren't just being found in the same script.
I reverted back to 1.9 but its still doing the same thing. Currently I have installed ruby 2.1.6. I am loading pages with Watir-webdriver and open-uri. The following page is being opened by open-uri.
For an example, here is my code:
htmlPage = '<html>
<head></head>
<body>
<table width="100%" border="1">
<tbody>
<tr valign="top">
<td width="38%" bgcolor="#EFEFEF">
<b>
<font size="4">NPL Listing History</font>
</b>
</td>
<td width="62%" bgcolor="#EFEFEF">
<b>
<font size="4">Dates</font>
</b>
</td>
</tr>
</tbody>
</table>
</body>
<html>'
page = Nokogiri::HTML(htmlPage)
puts page.css("table [border='1']")
This should get me the table with border 1 but I get nil/null.
Am I doing something wrong? Or something I am missing?
Thanks!
Your problem is the space. In CSS selectors whitespace is the descendant combinator, so table [border='1'] means "all descendants of a table that have a border attribute equal to 1. What you want is table[border='1'], which means "all table elements that have a border attribute equal to 1."

Image border does not work in Outlook 2010/2007

Here is the issue: I would like a white border on the picture, but when I send it to my outlook 2007 or 2010, it's not showing. Here is the code for the image in question:
<img src="my.jpg" alt="" width="220" height="220" border="3" style="border:3px solid #FFF;" />
Is there a fix out there for this issue? I feel like I've tried everything and nothing's worked.
This did render a border, but it's not an ideal solution because there is a space between the image and border.
<table width="220" height="220" border="0" cellspacing="0" cellpadding="0" style="border:3px solid #FFF;">
<tr>
<td>
<img src="my.jpg" alt="" width="220" height="220" border="0" title="70's Styled House and Pool" />
</td>
</tr>
</table>
I think you will have to wrap it in something. How about Span:
s = "<html><body>" _
& "<span style='display:inline-block;padding:5px;border:5px solid #fff;'>" _
& "<img src='z:\docs\image1.jpg' alt='' width=220 height=220></span>" _
& "</body></html> "
Set oEmail = Application.CreateItem(olMailItem)
oEmail.HTMLBody = s
oEmail.Display
I couldn't get the SPAN solution to work (I suspect because of extra code added by my CMS).
My solution was to wrap the image in a table with cellpadding set to the desired border width, and bgcolor set to the desired border colour. Hardly semantic, but that's Outlook's fault.
One of your issues is that hex color short-hand isn't supported in email. So you should be using all six hex digits.
<img
src="http://example.com/image.jpg"
alt=""
width="220"
height="220"
border="3"
style="border:3px solid #ffffff;" />

Firefox displays 3 columns in a table, IE8 only 2

Would love some help here... Firefox displays the last column in the table (an image they click on to edit their email address, it's a link), and IE8 displays nothing for the last column (doesn't even appear to display a column!) I've left out other rows in the table, but similar stuff happens.
Anyone know why?
<table class="profile-display">
<tr>
<td style="text-align: right; color: red;"> Email address: </td>
<td class="profile-content"> <?php echo("$evar"); ?> </td>
<td> <a href="profile_change.php?edit=13"
<img src="../images/writegreen.png" class="profile-edit" alt="Edit"
title="Edit Email Address"
border="0" />
</a>
</td>
</tr>
</table>
Your <a> tag is missing its >. That will cause a browser to not recognize the end of the tag until the first > it sees, which is the end of the img tag. Frankly, I'm surprised that Firefox shows the img.
Edit: Other common causes of this problem are missing quotes and misspelled tags.

Resources