I have an old program (15 years old?) that generates HTML attachments to emails. Basically, contract details get attached, along with signatures. The company wants to now send PDF attachments instead.
I tried to open the HTML attachments programmatically in MS Word, then SaveAs type 17 (PDF). Issue is, my embedded background images -- those important signatures -- do not open in Word.
Any have any better ideas, or workarounds?
I tried to open HTML like this in Word:
<HTML>
<HEAD>
<STYLE TYPE="TEXT/CSS">
.VERYSMALL {FONT-FAMILY:Arial; FONT-SIZE:7pt; FONT-WEIGHT:BOLD}
.SMALL {FONT-FAMILY:Arial; FONT-SIZE:8pt}
.REGULAR {FONT-FAMILY:Courier New; FONT-SIZE:10pt}
.HUGE {FONT-FAMILY:Courier New; FONT-SIZE:12pt; FONT-WEIGHT:BOLD}
#media print {
.no-print, .no-print * { display: none !important; } }
</STYLE>
</HEAD>
<BODY class=REGULAR>
<TABLE width=660>
<TR><TD> </TD></TR>
</TABLE>
<TABLE border=0 width=660>
<TR><TD align=center width=20% class=VERYSMALL>
</TD>
<TD width=60% align=center class=HUGE>XYZ & CO., INC.
</TD>
<TD align=center width=20% class=VERYSMALL>
</TD></TR>
<TR><TD align=center width=20% class=VERYSMALL>
TELEPHONE
</TD>
<TD width=60% align=center class=SMALL>
500 MAIN ST, NY 10001
</TD>
<TD align=center width=20% class=VERYSMALL>
TELEX
</TD></TR>
<TR><TD align=center width=20% class=VERYSMALL>
(555) 555-5555
</TD>
<TD align=center width=60%>
</TD>
<TD align=center width=20% class=VERYSMALL>
</TD></TR>
<TR><TD align=center width=20% class=VERYSMALL>
FAX
</TD>
<TD align=center width=60% class=VERYSMALL>
</TD>
<TD align=center width=20% class=VERYSMALL>
</TD></TR>
<TR><TD align=center width=20% class=VERYSMALL>
(555) 555-5555
</TD>
<TD align=center width=60% class=VERYSMALL>
</TD>
<TD align=center width=20% class=VERYSMALL>
</TD></TR>
</TABLE>
<BR>
<TABLE width=660 class=REGULAR>
<TR>
<TD width=100> </TD>
<TD width=55> </TD>
<TD width=195> </TD>
<TD width=20> </TD>
<TD width=50> </TD>
<TD width=80> </TD>
<TD width=80> </TD>
<TD width=80> </TD>
</TR>
<TR>
<TD colspan=2 valign=top align=Left>Contract Number:</TD>
<TD valign=top>96549</TD>
<TD valign=top align=Right colspan=2> </TD>
<TD valign=top colspan=3> </TD>
</TR>
<TR>
<TD colspan=2 valign=top align=Left>Contract Date:</TD>
<TD valign=top>October 12, 2022</TD>
<TD valign=top colspan=5> </TD>
</TR>
<TR>
<TD colspan=8> </TD>
</TR>
<TR>
<TD align=left valign=top>SELLER:</TD>
<TD valign=top colspan=7>ABC Co<BR>
A One Business Center<BR>
La Piece 3<BR>
1180 Rolle, Switzerland</TD>
</TR>
<TR>
<TD colspan=8> </TD>
</TR>
<TR>
<TD align=left valign=top>BUYER:</TD>
<TD valign=top colspan=7>XYZ and Co., Inc.<BR>
Main St<BR>
N.Y. 10001, USA</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>COMMODITY:</TD>
<TD colspan=7>CRUDE PALM OIL, in bulk. Malaysian/Indonesian origin at seller's option. </TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>QUANTITY:</TD>
<TD colspan=7>250 Metric Tons</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>SHIPMENT:</TD>
<TD colspan=7>June, 2023</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>PRICE:</TD>
<TD colspan=7>USD 1022.50 per metric ton CIF Rotterdam</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>ANALYSIS/ WEIGHTS:</TD>
<TD colspan=7>Landed analysis and landed weights to govern.</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>PAYMENT:</TD>
<TD colspan=7>99% cash against documents on/before vessels arrival at port of destination, but not later than 45 days from Bill of Lading Date, unless documents are presented thereafter. Balance to be settled on determination of landed weight and quality.</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
<TR>
<TD valign=top align=left>SPECIAL CONDITIONS:</TD>
<TD colspan=7>This contract is subject to the rules and regulations of FOSFA-80, including sticker AS-9 and in compliance with EU-1 regulations.<BR><BR>CIF Rotterdam Traceability terms.<BR><BR>FFA: Max 5% at time of shipment, basis 5% FFA on arrival. M&I basis pure on arrival.<BR><BR>OP #22101366</TD>
</TD>
</TR>
<TR><TD colspan=8> </TD></TR>
</TABLE><BR>
<BR><TABLE width=660 class=REGULAR>
<TR>
<TD width=24> </TD>
<TD valign=top colspan=2 width=276>XYZ and Co., Inc.</TD>
<TD width=24> </TD>
<TD valign=top colspan=2 width=276>ABC</TD>
</TR>
<TR>
<TD width=24> </TD>
<TD valign=top colspan=2 width=276>(Buyer)</TD>
<TD width=24> </TD>
<TD valign=top colspan=2 width=276>(Seller)</TD>
</TR>
<TR>
<TD colspan=6> </TD>
</TR>
<TR>
<TD width=24> </TD>
<TD valign=top width=24>By:</TD>
<TD valign=bottom width=252 style="background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALoAAAAtCAYAAAAZbXEKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAACGsSURBVHhe7X0JnFxVne5Xt6qrqqt639JJp7OTFWQJixp2AsqioIzI8MIWB1TG51PnMeA4LugwOvBDRJ2HPnlqEIIoBmUTwrDIlrBkDwnZmiS972vt2/u+c+vSRXd1AgMJBPrrnK67nHvuued85////uee6rgyBMYxjncdcaQRgwsFyGT8SKcBy5WEy4qYY4AXscQgPB43j7u470MGHljm2ncfB6rccXzo4WEqZHLD5UqTzEA0apHkxWhujGPDukZ4PaU8HjQDATxzIDFO9HEcIIjUIrsseoYWPYNAwELT6wl8+7o78fPbHkJ7c5x5RHC3yX8gMS5dxnFAkE5lkEqRxlQpFkWJ5Enr3jBu/Le7cd2/fA57dnXCW1iKhcfXgCMBVoGLuVJZuov47y7GLfo4Dg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N4OGWhe5qf3LPDPx9G5BJ4ZBqJfZ37oGLks+a2wcg0NvR3g5Ro1ak0PF4LU+qmY2+DjG4ZYiE3Hn5oJU482Q5MM/oTiGLkfpr5w2eWx/H+hayylLSxzoptEuaL4Pob/Gtfsb8QvX1rD2YeNgPTzBfkZfXJ8IyGxb4x/h/qjuN9Bb39N7R1648a6c17EaJDLjz2YDuCxUPYunUPjlo4ByedXkeaZ+MeLQPQvzGtOvD/AaKZSof9O0A9AAAAAElFTkSuQmCC) no-repeat"><BR><BR><BR><HR>(Signature)</TD>
<TD valign=top width=24> </TD>
<TD valign=bottom width=252><BR><HR>(Signature)</TD>
<TD valign=top width=24> </TD>
</TR>
<TR>
<TD colspan=6> </TD>
</TR>
</TABLE><BR></FONT>
</BODY>
</HTML>
Change your media line to match A4 output, it will resolve page size (note those margins for later).
#media print { #page { margin: 0; size: 210mm 297mm ; } body { margin: 0; } }
The browser settings should be default to image, open the test.html and print one with graphics on to check its working.
then in the folder at the console line run
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --headless --print-to-pdf="%CD%\output.pdf" "%CD%\test.html"
Then type output.pdf and check the result, it should be up to the left.
there should be no visible header footer (because the margins obscure them)
Avoid adjusting that first value so I suggest for your case the second as body { margin: 12mm; } } should be about right (1/2"), too much will trip a new blank page, as seen here, by the page 1/2 :-
For a full folders worth run
(NOTE if using a batchfile.bat change %F to %%F and the 2 x %CD%\%~nF edit to %CD%\%%~nF)
for /f "usebackq delims==" %F in (`dir /b *.html`) do ("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --headless --print-to-pdf="%CD%\%~nF.pdf" "%CD%\%~nF.html")
I'm trying to hide the second table below and make it appear when customers select the debit option from the drop down menu at the top. I'm relatively new to this so any help is greatly appreciated!
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select>
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
</td>
<span style="text-align: center">
</div>
</span>
</tr>
</tbody>
</table>
Add id="table2" to your table and this CSS to start hidden:
#table2 {
visibility:hidden;
}
And add to your <select> the onchange="ShowHide(this)" every change in select call the ShowHide function.
With javascript add this function to turn visible the table if the option selected is debit:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
Online example:
function ShowHide(select){
var table2 = document.getElementById("table2");
if(select.value == "tracer ach debit"){
table2.style.visibility="visible";
}else{
table2.style.visibility="hidden";
}
}
#table2 {
visibility:hidden;
}
<table width="300" height="75" border="2">
<tbody>
<tr>
<th scope="col">
<span style="font-size: 13px">Payment Method:</span>
<select id="select" onchange="ShowHide(this)">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select>
</th>
</tr>
</tbody>
</table>
<br>
<table width="300" height="300" border="2" id="table2">
<tbody>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td valign="top">
<span style="font-size: 13px">Bank Account:</span>
</td>
<td>
<textarea rows="1" cols="30"></textarea>
<span></span>
</td>
</tr>
</tbody>
</table>
function paymentChangeHandler(event) {
var value = event.target.value;
var bank = document.getElementById("bank_info");
if (value.indexOf('debit') !== -1) {
bank.style.visibility = "visible";
} else {
bank.style.visibility = "hidden";
}
}
var selector = document.getElementById("payment_method");
selector.onchange = paymentChangeHandler;
<table width="723" height="75" border="2">
<tbody>
<tr>
<th width="248" scope="col"><span style="font-size: 13px">Payment
Method:</span>
<select id="payment_method">
<option value=""></option>
<option value="tracer ach credit">Credit</option>
<option value="tracer ach debit">Debit</option>
</select> </th>
</tr>
</tbody>
</table>
<br>
<table width="723" height="558" border="2" id="bank_info" style="visibility:hidden;">
<tbody>
<tr style="text-align: center; font-size: 13px;">
<td height="40" colspan="2">
</td>
</tr>
<tr>
<td height="24" valign="top"><span style="font-size: 13px">Bank
Account:</span>
</td>
<td height="26"><textarea rows="1" cols="50">
</textarea> </td>
<span style="text-align: center">
</span>
</tr>
</tbody>
</table>
Add id's for payment method drop down control and bank table and add style visibility:hidden to bank table.
I have a complex html file that I need to parse in Objective-C. The html looks like
<HTML>
<TABLE width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" align="left" valign="top"><img src="http://www.indianrail.gov.in/main_text_left_top2.gif" alt="" width="8" height="8"></td>
<td width="100%" align="left" valign="top" class="text_rail_top"><img src="http://www.indianrail.gov.in/blank.gif" alt="" width="1" height="8"></td>
<td width="10" align="right" valign="top"><img src="http://www.indianrail.gov.in/main_text_rgt_top2.gif"alt="" width="8" height="8" ></td>
</tr>
<tr>
<td height="400" align="right" valign="top" class="text_rail_left"></td>
<td width="100%" align="left" valign="top" class="text_back_color"><table border="0" cellPadding="0" cellSpacing="0" width="100%"><tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="0"><tr> <td align="middle"> <FONT SIZE = "1"> Indian Railways Online Website: <b><a TITLE = "Passenger Reservation System - CONCERT" href="http://www.indianrail.gov.in/index.html" target="_blank">http://www.indianrail.gov.in</b></a> designed and hosted by CRIS.</FONT> </td></tr></table></td>
</tr><tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><table border="0" width="100%" /></td>
</tr>
<tr>
<td align="center" valign="top" class="inside_heading_text" colspan="4"><br />Trains Between A Pair of Stations </td>
</tr>
<td colspan="4"> </td>
</tr>
<tr>
<td colspan="4" align="center" valign="top" class="Enq_heading"> You Queried For <SCRIPT LANGUAGE="JavaScript" SRC= "/js/inet_srcdest.js">
function getCookie(http://www.indianrail.gov.in/tbisip_400x400.htm)</SCRIPT>
<link href="http://www.indianrail.gov.in/cris_google.css" media="all" rel="Stylesheet" type="text/css" />
<script language ="JavaScript">
var searchQuery ='MUMBAI CENTRAL DELHI '
</script><FORM NAME="Accavl" METHOD="POST" ACTION="http://www.indianrail.gov.in/cgi_bin/inet_accavl_cgi1.cgi">
<TR>
<TD valign="top"><table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_border">
<TR class="heading_table_top">
<TH>Origin</TH>
<TH>Destination</TH>
</TR>
<TR>
<TD class="table_border_both">MUMBAI CENTRAL -[BCT ]</TD>
<TD class="table_border_both">DELHI -[DLI ]</TD>
</TR>
</TABLE>
</TD></TR>
<TR><td> </td></TR>
<TR>
<td class="main_text">Enter Quota:</td>
<td><SELECT NAME="lccp_quota" SIZE="1" >
<OPTION VALUE="CK">Tatkal Quota
<OPTION VALUE="LD">Ladies Quota
<OPTION VALUE="DF">Defence Quota
<OPTION VALUE="FT">Foreign Tourist Quota
<OPTION VALUE="SS">Lower Berth Quota$
<OPTION VALUE="YU">Yuva Quota
<OPTION VALUE="DP">Duty Pass Quota
<OPTION VALUE="HP">Handicaped Quota
<OPTION VALUE="PH">Parliament House
<OPTION selected VALUE="GN">General Quota
</SELECT></TD></tr>
<tr>
<td class="main_text">Journey Date:</td><td><INPUT NAME="lccp_day" SIZE="2" VALUE="11" onchange="return changedate()"><SELECT NAME="lccp_month" SIZE="1" onClick="return changedate()"><OPTION selected VALUE="5">May<OPTION VALUE="6">Jun<OPTION VALUE="7">Jul</SELECT></TD></tr><INPUT TYPE="HIDDEN" NAME="lccp_classopt" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class1" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class2" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class3" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class4" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class5" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class6" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class7" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class8" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_class9" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_cls10" SIZE="2" VALUE="ZZ"><INPUT TYPE="HIDDEN" NAME="lccp_age" SIZE="2" VALUE="ADULT_AGE"><tr>
<td> </td><td><INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitacc" ONCLICK="return submitavailability(0)" VALUE="Get Availability"> <INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitfare" ONCLICK="return submitfare(0)" VALUE="Get Full Fare"> <INPUT TYPE="Button" CLASS="btn_style" NAME="lccp_submitpath" ONCLICK="return submitroute(0)" VALUE="Get Schedule"> <INPUT TYPE="BUTTON" CLASS="btn_style" NAME="lccp_submitrun" ONCLICK="return submitrun(0)" VALUE="Get Running Status"></td></tr></table><br>
<TABLE BORDER ALIGN=center><TABLE width="98%" border="1" bordercolor="#993300" align="center" cellpadding="3" cellspacing="1" class="table_border_both_left"><tr class="heading_table_top">
<TH ROWSPAN = 2 width="9%" >Train No.</TH>
<TH ROWSPAN = 2 width="20%" >Train Name</TH>
<TH ROWSPAN = 2 width="15%" >Origin</TH>
<TH ROWSPAN = 2 width="8%" >Dep.Time</TH>
<TH ROWSPAN = 2 width="14%" >Destination</TH>
<TH ROWSPAN = 2 width="7%" >Arr.Time</TH>
<TH COLSPAN = 7 width="7%" >Days Of Run</TH>
<TH COLSPAN = 10 width="7%">Classes</TH>
</TR>
<TR class="heading_table_top">
<TH width="3%">M</TH>
<TH width="3%">T</TH>
<TH width="3%">W</TH>
<TH width="3%">T</TH>
<TH width="3%">F</TH>
<TH width="3%">S</TH>
<TH width="3%">S</TH>
<TH width="3%">1A</TH>
<TH width="3%">2A</TH>
<TH width="3%">FC</TH>
<TH width="3%">3A</TH>
<TH width="3%">CC</TH>
<TH width="3%">SL</TH>
<TH width="3%">2S</TH>
<TH width="3%">3E</TH>
</TR>
<TR><TD><INPUT TYPE="RADIO" NAME="lccp_trndtl" VALUE="19019BDTSNZM YYYYYYYY "ONCLICK="return farefill('19019BDTSNZM YYYYYYYY ','19019','BDTS',0,0,1,0,1,0,1,0,0,0,0)" CHECKED>19019</TD>
<TD ALIGN =Center TITLE = " Please look the following same trains list also ">+DEHRADUN EXP <A NAME="BACKSAMETRN"></A>
<TD ALIGN =Center TITLE="Station CodeBDTS">BANDRA TERMINUS</TD>
<TD ALIGN = Center>00:05</TD>
<TD ALIGN = Center TITLE="Station Code NZM ">H NIZAMUDDIN </TD>
<TD ALIGN = Center>05:25</TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class2" VALUE="2A" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','Y','N','N','N','N','N','N','N','N')" CHECKED>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class4" VALUE="3A" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','N','N','Y','N','N','N','N','N','N')">
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class6" VALUE="SL" ONCLICK="return deselectclass(1,0,1,0,1,0,1,0,0,0,0,'N','N','N','N','N','Y','N','N','N','N')">
<TD>-</TD>
<TD>-</TD>
</TR></FONT>
<TR><TD><INPUT TYPE="RADIO" NAME="lccp_trndtl" VALUE="19023BCT NDLSYYYYYYYY "ONCLICK="return farefill('19023BCT NDLSYYYYYYYY ','19023','BCT ',0,0,0,0,0,0,2,1,0,0,0)">19023</TD>
<TD ALIGN =Center TITLE = " Please look the following same trains list also ">+FZR JANATA EXP <A NAME="BACKSAMETRN"></A>
<TD ALIGN =Center TITLE="Station CodeBCT ">MUMBAI CENTRAL </TD>
<TD ALIGN = Center>07:25</TD>
<TD ALIGN = Center TITLE="Station Code NDLS">NEW DELHI </TD>
<TD ALIGN = Center>12:45</TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD><FONT COLOR = green><B>Y</B></TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD>-</TD>
<TD><INPUT TYPE="RADIO" Name="lccp_class6" VALUE="SL" ONCLICK="return deselectclass(2,0,0,0,0,0,2,1,0,0,0,'N','N','N','N','N','Y','N','N','N','N')">
<TD><INPUT TYPE="RADIO" Name="lccp_class7" VALUE="2S" ONCLICK="return deselectclass(2,0,0,0,0,0,2,1,0,0,0,'N','N','N','N','N','N','Y','N','N','N')">
<TD>-</TD>
</TR></FONT>
</TABLE>
</BODY>
</HTML>
I want to parse the html using hpple for the following output
19019
BANDRA TERMINUS
00:05
H NIZAMUDDIN
05:25
2A
3A
SL
19023
MUMBAI CENTRAL
07:25
NEW DELHI
12:45
SL
2S
I started with the following xpath query
NSString *tutorialsXpathQueryString = #"//table[#class='table_border_both_left']//td";
But it returns way to many results and is difficult to parse further. Can someone help me with the xpath query so I can parse this more efficiently.
Thanks!
You can locate table rows with this:
List<WebElement> tableRows = findElements(By.xpath("//TABLE[#class='table_border_both_left']//tr[not(#class='heading_table_top')]"));
In a row find the expected data :
for (WebElement row : tableRows) {
String trainNo = row.findElement(By.xpath("td[1]")).getText(); //or use xpath : td[1]/text()
String origin = row.findElement(By.xpath("td[3]")).getText(); //or use xpath : td[3]/text()
String deptTime = row.findElement(By.xpath("td[4]")).getText(); //or use xpath : td[4]/text()
String destination = row.findElement(By.xpath("td[5]")).getText(); //or use xpath : td[5]/text()
String arrTime = row.findElement(By.xpath("td[6]")).getText(); //or use xpath : td[6]/text()
List<WebElement> radioButtons = row.findElements(By.xpath("td//input[not(#name='lccp_trndtl')]"));
// or use xpath : //TABLE[#class='table_border_both_left']//tr[not(#class='heading_table_top')]//td//input[not(#name='lccp_trndtl')]//#value
for (WebElement radio : radioButtons) {
String value = radio.getAttribute("value");
}
}
Sorry for my code but I'm using Selenium WebDriver in Java. I hope the given xpath expressions will be useful.
You can use an XPath union expression (i.e. |) to return the direct text() children of your TD elements and also the #VALUE attribute of your INPUT elements:
//TABLE[#class='table_border_both_left']//TD(text() | INPUT[#TYPE eq "RADIO"]/#VALUE)
I am currently using perl HTML::Strip to extract text from my HTML file, however i have run into a minor problem with HTML specific spaces ie the " ". For some reason HTML::Strip->parse() doesnt seem to work in this instance. I know i can run the replace command later on. But i was checking to see if there another way i can accomplish this by tweaking the new() constructor? Thanks in advance
Perl Code:
my $hs = HTML::Strip->new();
my $line = join('',#htmlSource);
my $clean_text = $hs->parse( $line );
push #processedLines, grep { /\S/ } split (/\n/,$clean_text);
foreach my $f ( #processedLines ) {
print "$f\n";
}
Sample Output:
CBD_UnitTest
MtrTempEst
MtrTempEst_Init1 (C1-Coverage: 100.00 %, 1 out of 1 Testcases passed)
LeadLagFilt (C1-Coverage: 100.00 %, 1 out of 1 Testcases failed)
AssMechFiltInit (C1-Coverage: 100.00 %, 1 out of 1 Testcases passed)
Sample Dataset:
<table bgcolor="white" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<table width="100%" cellspacing="0" cellpadding="1" bgcolor="white" border="0">
<tr bgcolor="#dcdcdc">
<td width="1%" bgcolor="white">
<img border="0" src="pictures/batch_module_notok.jpg"/>
</td>
<td colspan="3" width="1%">
<font face="tahoma" size="-2" color="black">
CBD_UnitTest
</font>
</td>
<td width="1%">
</td>
<td width="1%">
</td>
<td width="1%">
<img border="0" src="pictures/batch_check_notok.gif"/>
</td>
</tr>
<tr bgcolor="white">
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
<img border="0" src="pictures/batch_module_notok.jpg"/>
</td>
<td colspan="2">
<font face="tahoma" size="-2" color="black">
MtrTempEst
</font>
</td>
<td width="1%">
</td>
<td width="1%">
</td>
<td width="1%">
<img border="0" src="pictures/batch_check_notok.gif"/>
</td>
</tr>
<tr bgcolor="#dcdcdc">
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
<img border="0" src="pictures/batch_ok.jpg"/>
</td>
<td>
<a href="#CBD_UnitTest:MtrTempEst:ts_MtrTempEst_Init1"><font face="tahoma" size="-2" color="black">
MtrTempEst_Init1 (C1-Coverage: 100.00 %, 1 out of 1 Testcases passed)
</font></a>
</td>
<td width="1%">
</td>
<td width="1%">
</td>
<td width="1%">
<img border="0" src="pictures/batch_check_ok.gif"/>
</td>
</tr>
<tr bgcolor="#FF0000">
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
<img border="0" src="pictures/batch_notok.jpg"/>
</td>
<td>
<a href="#CBD_UnitTest:MtrTempEst:ts_LeadLagFilt"><font face="tahoma" size="-2" color="white">
<b>LeadLagFilt (C1-Coverage: 100.00 %, 1 out of 1 Testcases failed)</b>
</font></a>
</td>
<td width="1%">
<a name="LeadLagFilt_0"></a>
</td>
<td width="1%">
</td>
<td width="1%">
<img border="0" src="pictures/batch_check_notok.gif"/>
</td>
</tr>
<tr bgcolor="#dcdcdc">
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
</td>
<td width="1%" bgcolor="white">
<img border="0" src="pictures/batch_ok.jpg"/>
</td>
<td>
<a href="#CBD_UnitTest:MtrTempEst:ts_AssMechFiltInit"><font face="tahoma" size="-2" color="black">
AssMechFiltInit (C1-Coverage: 100.00 %, 1 out of 1 Testcases passed)
</font></a>
</td>
<td width="1%">
</td>
<td width="1%">
</td>
<td width="1%">
<img border="0" src="pictures/batch_check_ok.gif"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
Have you installed HTML::Entities?
The docs for HTML::Strip state:
"HTML::Strip will only attempt decoding of HTML entities if HTML::Entities is installed."
Figured out the answer from the link to HTML::Entities above. Thx #edibleEnergy
use HTML::Strip;
use HTML::Entities;
my $hs = HTML::Strip->new();
my $line = join('',#htmlSource);
_decode_entities($line, { nbsp => "" }, 1);
my $clean_text = $hs->parse( $line );
push #processedLines, grep { /\S/ } split (/\n/,$clean_text);
foreach my $f ( #processedLines ) {
print "$f\n";
}
I understand that we could just use the simple replace here (ie s/\ //g) But the above example works for instance with or without the ";" at the end. Please check the link provided in the #edibleEnergy's answer.
I am running the following as a simple html file.Problem is that when i am running it on firefox i get a different view than on chrome i.e extra space at the end of the page in the table in case of chrome because of which i am getting extra pages at the end in print preview,i want that it should look as in case of firefox.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--last modified on Tuesday, June 05, 2001 08:55 AM -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<META NAME="GENERATOR" Content="Visual Page 2.0 for Windows">
<META NAME="Author" Content="NetCorrespondence.com">
<TITLE>Printing Work Order</TITLE>
</HEAD>
<BODY>
<img src="/CFFileServlet/_cf_image/_cfimg5646601472618022292.PNG" alt="" />
<P>
<TABLE BORDER="2" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%">
<TR>
<TD WIDTH="100%" VALIGN="TOP">
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD WIDTH="50%"><b><font size="+1"> </font></b></TD>
<TD WIDTH="50%">
<P ALIGN="RIGHT"><b>WORKORDER - Pest Control Services</b>
</TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP">
<table>
<tr>
<td><img src="http://209.123.166.68/E7CC71EB-756D-462F-9641B46BA6927E9B/pestlogo.jpg" alt="" width="100" height="125" border="0"></td>
<td>
<FONT SIZE="5">
Preferred Pest Services, Inc D/B/A Pest Pro Services
</FONT>
<BR>
32 Drysdale Street<BR>
Staten Island, NY, 10314<BR>
Tel:718 983-0004<BR>
Fax:718-477-0333 Email:pestprosolutions#gmail.com
<BR>
Sales Representative: Debbie
</td>
</tr>
</table>
</TD>
<TD WIDTH="50%" VALIGN="TOP">
<DIV ALIGN="RIGHT">
<P>
<TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" WIDTH="95%">
<TR>
<TD><b>Order#:</b></TD>
<TD> 92681</TD>
</TR>
<TR>
<TD><b>JobDate:</b></TD>
<TD> <b>10/07/2011</b></TD>
</TR>
<TR>
<TD><b>Day of Week:</b></TD>
<TD> <b>Friday</b></TD>
</TR>
<TR>
<TD><b>Location:</b></TD>
<TD> Manhattan</TD>
</TR>
<TR>
<TD><b>Start Time:</b></TD>
<TD> 12:00 PM</TD>
</TR>
<TR>
<TD width="50%"><b>CFP:</b></TD>
<TD width="50%"> </TD>
</tr>
<tr>
<TD width="50%"><b>CN:</b></TD>
<TD width="50%"> </TD>
</TR>
<tr>
<TD width="50%"><b>Day Number:</b></TD>
<TD width="50%"> 1/1 </TD>
</TR>
</table>
</DIV>
</TD>
</TR>
<TR>
<TD WIDTH="50%"><b>FOR OFFICE USE ONLY:</b></TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP"><B>CUSTOMER INFORMATION:</B><BR><BR>
Company: Lemle and Wolff<BR>
Christopher Anelante<BR>
Address: 5925 Broadway<BR>
Address: Bronx, NY 10463<BR>
Telephone: 718 884-7676 Fax: 718 884-5300<BR>
Email: <BR>
<TD WIDTH="50%" VALIGN="TOP"><B>Billing Address:</B><BR><BR>
Company: Lemle and Wolff<BR>
Christopher Anelante<BR>
Address: 5925 Broadway<BR>
Address: Bronx, NY 10463<BR>
</TD>
</TR>
<TR>
<TD WIDTH="50%"><b>JOB SITE:</b></TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2">
<b>JOB INFORMATION:</b><BR>
2651 Eighth Avenue<br>
New York, NY 10030<br>
Primary Contact: Eriberto Jacques 172*44*29419 Phone: 718 884-7676 Cell: Beeper:<br>
Notes:<BR>
JOB TYPE: Pest Control Services<BR>
<BR>
<BR>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><B>Job Description:</B>
Pest Control Services-First Friday of the month 12:00 PM
</TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2"><B>Special Instructions:</B><BR>
Service to all of 10 apartments in building thorough treatment for mice roaches and insects. MUST LIST ALL APARTMENTS IN BUILDING ON LIST. TREAT all common areas and basements and common areas. MUST SEE SUPER FOR ACCESS</TD>
</TR>
<TR>
<TD COLSPAN="2"><b>ORDER TOTALS</b></TD>
</TR>
<TR>
<TD COLSPAN="2">Service Price: $30.00 Parts: $0.00 Subtotal: $30.00 Tax: $2.51 Total: $32.51</TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2"><B>Parts:</B><BR>
<table width="90%" border="1" cellspacing="0" cellpadding="0"><tr>
<TR>
<TD WIDTH="49%"><b>ItemID</b></TD>
<TD WIDTH="24%"><b>Description</b></TD>
<TD WIDTH="20%"><b>Qty</b></TD>
<TD WIDTH="20%"><b>Price</b></TD>
<TD WIDTH="20%"><b>Total</b></TD>
</TR>
</TD>
</tr>
</table>
</TR>
<TR>
<TD COLSPAN="2"> </TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP">
<DIV>
<P><FONT SIZE="2">Please sign that job was completed and performed in a <BR>
satisfactory manner.</FONT></P>
<P><FONT SIZE="2">Name:___________________________<BR><br>
Authorized Signature:_____________________________<BR><br>
Title:__________ Date:__________<BR><br>
</FONT>
</DIV>
<P><FONT SIZE="2">Job Completed: [ ]Yes [ ]No </FONT><FONT SIZE="1"></FONT>
</TD>
<TD WIDTH="50%" VALIGN="TOP"><FONT SIZE="2">Persons on the Job<BR><BR>
<TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" WIDTH="74%">
<TR>
<TD WIDTH="49%"><FONT SIZE="2"><b>Name</b></FONT></TD>
<TD WIDTH="24%"><FONT SIZE="2"><b>Start Time</b></FONT></TD>
<TD WIDTH="20%"><FONT SIZE="2"><b>End Time</b></FONT></TD>
</TR>
<TR>
<TD WIDTH="49%">Carlos Almonte</TD>
<TD WIDTH="24%"> </TD>
<TD WIDTH="20%"> </TD>
</TR>
</TABLE>
<font size="-1"><br>Please use the back of this workorder for comments.</font></FONT></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<!---<p style="page-break-after: always"></p>--->
<table Align="Center" width="85%">
<tr>
<td valign="Top">
<font size="+4"><div align="center"><b><u>WARNING!!</u></b></div></font>
<div align="center"><font size="+3">To all residents of:</font></div><br>
<font size="+3"><div align="center">2651 Eighth Avenue</div></font>
<br>
<div align="center"><font size="+4">Your stairhalls will be cleaned on:</font></div></font>
<br><br>
<font size="+3"><div align="center">Friday Oct-07/2011 12:00PM-06:11PM</div></font>
<br><br>
<font size="+4">
<b>DANGER TO ANYONE ATTEMPTING TO ENTER STAIRWAY !!!!</b>
<BR><BR>
<b>MUST USE CAUTION WHEN USING THESE STAIRCASES FOR THE NEXT 48 HOURS!</b>
</font>
<br><br>
<font size="+3"><p align="right">Thank You for your cooperation,<br>
The Management</p></font>
</td>
</tr>
</table>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--last modified on Tuesday, June 05, 2001 08:49 AM -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<META NAME="GENERATOR" Content="Visual Page 2.0 for Windows">
<META NAME="Author" Content="NetCorrespondence.com">
<TITLE>Confirmation</TITLE>
</HEAD>
<BODY>
<P>
<TABLE BORDER="2" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%">
<TR>
<TD WIDTH="100%" VALIGN="TOP">
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD WIDTH="50%">
</TD>
<TD WIDTH="50%">
<P ALIGN="RIGHT"><font size="+1"><b>CONFIRMATION OF SERVICES<BR> for Pest Control Services</b></font>
</TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP">
<table>
<tr>
<td align="left" valign="Top">
</td>
<td valign="top">
<FONT SIZE="5">Pest Pro Services</FONT><BR>
32 Drysdale Street<BR>
Staten Island NY 10314<BR>
Tel:718 983-0004<BR>
Fax:718-477-0333
<BR>
</td>
</tr>
<tr>
<td colspan="2">Sales Representative: Debbie</td>
</tr>
</table>
</TD>
<TD WIDTH="50%" VALIGN="TOP">
<DIV ALIGN="RIGHT">
<P>
<TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" WIDTH="75%">
<TR>
<TD>Order#:</TD>
<TD> 92681</TD>
</TR>
<TR>
<TD>JobDate:</TD>
<TD> 10/07/2011</TD>
</TR>
<TR>
<TD>Location:</TD>
<TD> Manhattan</TD>
</TR>
<TR>
<TD>StartTime:</TD>
<TD> 12:00 PM</TD>
</TR>
</TABLE>
</DIV>
</TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP">Lemle and Wolff<BR>
Telephone: 718 884-7676 Fax: 718 884-5300<BR>
Billing Address: 5925 Broadway<br>
Address: Bronx, NY 10463<BR>
</TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD VALIGN="TOP" COLSPAN="2">
JOB TYPE: Pest Control Services<BR>
Attention: Eriberto Jacques 172*44*29419<BR>
Job Address: 2651 Eighth Avenue<BR>
Job City: New York
Borough or Town: Manhattan<BR>
<BR>
Site Manager/Super: Eriberto Jacques 172*44*29419 Tel: 718 884-7676
Beeper: Cell: Location
of Site/Mtc: Eriberto Jacques 172*44*29419<BR>
<BR>
</TD>
</TR>
<TR>
<TD WIDTH="50%"> </TD>
<TD WIDTH="50%"> </TD>
</TR>
<TR>
<TD WIDTH="50%" VALIGN="TOP"><BR>
Dear Customer,<br><br>
Thankyou for choosing us as your building maintenance company. Your building/s will be serviced on:<br>
<br>
<font size="+1"><b>Day:</b> Friday<br>
<b>Date:</b> Oct-072011<br>
<b>Start Time:</b> 12:00 PM<br></font>
<br>
Please post
any notices if applicable.
</TD>
<TD WIDTH="50%" VALIGN="TOP">
<B><FONT SIZE="2">SPECIAL INSTRUCTIONS:</FONT></B>
<br>
Service to all of 10 apartments in building thorough treatment for mice roaches and insects. MUST LIST ALL APARTMENTS IN BUILDING ON LIST. TREAT all common areas and basements and common areas. MUST SEE SUPER FOR ACCESS
<br>
<br>
<br>
<TABLE BORDER="1" CELLSPACING="1" WIDTH="80%">
<TR>
<TD WIDTH="67%"><FONT SIZE="2">Agreed Price:</FONT></TD>
<TD WIDTH="33%" Align="Right"><FONT SIZE="2">$30.00</FONT></TD>
</TR>
<TR>
<TD WIDTH="67%"><FONT SIZE="2">P.O. #:</FONT></TD>
<TD WIDTH="33%"></TD>
</TR>
</TABLE>
<br><br>
<b> All cancellations require at least 24 hours of notice to us
Failure to do so could result in extra charges.</b>
</TD>
</TR>
<TR>
<TD COLSPAN="2">
</TD>
</TR>
<TR>
<TD VALIGN="TOP">
Date Confirmed: <br>
Confirmed By:
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<!---<p style="page-break-after: always"></p>--->
First, make a stylesheet for your print layout:
<link rel="stylesheet" href="/css/print.css" type="text/css" media="print" />
Key there being media="print".
Next, reset the base style so it's cross-browser normalized. Check out YUI3's CSS reset syntax for a quick reference: http://yuilibrary.com/yui/docs/cssreset/
From there, you'll want to omit visual stuff people hate printing out, like logos, graphical navs, etc:
#logo, .nav-tab, .etc {
display:none;
}
Finally, set the page breaks so you don't get unintentional content-splitting across multiple pages:
#some-important-element {
page-break-before: always;
}
Once you set this up, you won't have to worry about cross-browser quirks interfering with your web-print renderings.