jsPDF from table with mixed image & text content - jspdf

I have been spending a lot of time working with jsPDF trying to create a pdf doc that uses a table with images in some cells and text in other cells. I am misunderstanding something critical. Even though I am converting the images to data urls, the images are not appearing in the final PDF. I have also tried .fromHTML but the resulting page is blank.
The only thing i can get to work so far is a straight, single column of divs with only a single item in each div. Using .fromHTML works in this way, but it doesn't seem to work with more than one div side-by-side limiting my ability to include a graphic border around the dynamic content in the middle of the doc, which is retrieved from URL-encoded pairs in the address.
So I've been trying to do it with a table instead. Here's a picture of what I am trying to achieve. Certificate Sliced . This is exported out of Photoshop using slices (shown). The table is quite simple, although it does have some colspans which could be part of my problem. I then used DataURL Maker to encode the graphic parts, and leaving the middle cells that have text-only alone as html text.
Here's the table as output from Photoshop (with original image links):
<html>
<head>
<title>Certificate 2015-table</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Save for Web Slices (Certificate 2015-table.psd) -->
<table id="Table_01" width="997" height="750" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5"><img src="images/small-table_01.png" width="997" height="222" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_02.png" width="86" height="46" alt=""></td>
<td colspan="3"><img src="images/small-table_03.png" width="826" height="46" alt=""></td>
<td><img src="images/small-table_04.png" width="85" height="46" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_05.png" width="86" height="45" alt=""></td>
<td colspan="3"><img src="images/small-table_06.png" width="826" height="45" alt=""></td>
<td><img src="images/small-table_07.png" width="85" height="45" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_08.png" width="86" height="74" alt=""></td>
<td colspan="3"><img src="images/small-table_09.png" width="826" height="74" alt=""></td>
<td><img src="images/small-table_10.png" width="85" height="74" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_11.png" width="86" height="75" alt=""></td>
<td colspan="3"><img src="images/small-table_12.png" width="826" height="75" alt=""></td>
<td><img src="images/small-table_13.png" width="85" height="75" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_14.png" width="86" height="56" alt=""></td>
<td colspan="3"><img src="images/small-table_15.png" width="826" height="56" alt=""></td>
<td><img src="images/small-table_16.png" width="85" height="56" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_17.png" width="86" height="54" alt=""></td>
<td colspan="3"><img src="images/small-table_18.png" width="826" height="54" alt=""></td>
<td><img src="images/small-table_19.png" width="85" height="54" alt=""></td>
</tr>
<tr>
<td colspan="2" rowspan="3"><img src="images/small-table_20.png" width="565" height="99" alt=""></td>
<td><img src="images/small-table_21.jpg" width="255" height="19" alt=""></td>
<td colspan="2" rowspan="3"><img src="images/small-table_22.png" width="177" height="99" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_23.png" width="255" height="22" alt=""></td>
</tr>
<tr>
<td><img src="images/small-table_24.png" width="255" height="58" alt=""></td>
</tr>
<tr>
<td colspan="5"><img src="images/small-table_25.png" width="997" height="78" alt=""></td>
</tr>
<tr>
<td><img src="images/spacer.gif" width="86" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="479" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="255" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="92" height="1" alt=""></td>
<td><img src="images/spacer.gif" width="85" height="1" alt=""></td>
</tr>
</table>
<!-- End Save for Web Slices -->
</body>
The goal of course will be to have a single certificate that can be customized for each student and each course that can be downloadable as PDF. Is it possible to include pictures in cells of a table and save with jsPDF?
Thanks for any help,
--Kevin

Related

Extract text from a specific row in the table with Capybara

Friends for me to finish my test and I just need to extract the text of the tooltip from the specific line of the table. Thomas Walpole has helped me a lot. Now I can read the excel spreadsheet and I will validate with each line of the application.
****** I read excel and get the first line *************
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet.open('c:/temp/Pasta1.xls', "r")
sheet = book.worksheet 0
#sheet.each do |row|
pp hydrometer = sheet.row(1)
****** reading the specific row of the table *************
I just need to extract this text save in a variable and validate with the hydrometer variable that stores the row of my excel sheet
expect(page).to have_css('tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip="Invisível"]')
see the code
<tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','bdb','BtnDropDownRow#',1,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','bdb','Select#',1,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowEven tvRoll tvRowSelected" style="cursor:pointer;">
<td valign="center" align="left" class="tvCell">XWFMSLETMATRICOLA_E</td>
<td valign="center" align="left" class="tvCell"> Nº Hidrômetro</td>
<td align="left" class="tvCell" valign="center" nowrap=""></td>
<td valign="center" align="left" class="tvCell"></td>
<td align="left" width="1" class="tvCell" valign="center" tooltip="[AIMPMATRICOLA]">
<button onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','bdb','AUTOFILLBTN#',1,'','','','');" class="but butAct" tabindex="0" tooltip="Preenchimento automático ativado" type="BUTTON">
<div><img src="r/std/icons/checkboxselected64.png" class="icon" draggable="false" align="absmiddle"></div>
</button>
</td>
<td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
<td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
<div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','bdb','BtnDropDownRow#',1,'','','','');" class="but">
<div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
</div>
</td>
</tr>
<tr oncontextmenu="if(!this.cancelEvent) {sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','bdb','BtnDropDownRow#',2,'','','');return false;} delete this.cancelEvent;" onclick="if(notSelecting()) sendEvent(0,event,this,true,0,'TVXWFMTGINSTATOCE','bdb','Select#',2,'','','');" onmousedown="if(event.ctrlKey) this.cancelEvent=true;" class="tvRow tvRowOdd tvRoll" style="cursor:pointer;">
<td valign="center" align="left" class="tvCell">XWFMSLETLETTURA_E</td>
<td valign="center" align="left" class="tvCell"> Leitura</td>
<td align="left" class="tvCell" valign="center" nowrap=""></td>
<td valign="center" align="left" class="tvCell"></td>
<td align="left" width="1" class="tvCell" valign="center" tooltip=""></td>
<td valign="center" align="center" class="tvCell"><img tooltip="Invisível" src="r/std/static/minus16.gif"></td>
<td align="center" width="30" style="line-height:1px;padding:0px;" class="tvCell" valign="center">
<div onclick="event.cancelBubble=true;sendEvent(0,event,this,searchImage(this),0,'','bdb','BtnDropDownRow#',2,'','','','');" class="but">
<div><img src="r/std/icons/menu64.png" class="icon" draggable="false" align="absmiddle"></div>
</div>
</td>
</tr>
If hydrometer contains the text you're checking for just interpolate it in the CSS selector you're using
expect(page).to have_css("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip='#{hydrometer}']")
Since your going through a loop you'd probably also want to interpolate the row number but I don't know what variable you have that in
expect(page).to have_css("tr.tvRow:nth-child(#{row_number}) .tvCell:nth-child(6) img[tooltip='#{hydrometer}']")
If you really want to get the tooltip text for a specific row you would do
text = find("tr.tvRow:nth-child(2) .tvCell:nth-child(6) img[tooltip]")[:tooltip] # get the tooltip attribute value from the 2nd row
but doing that and then comparing it to some other string is bad practice and will lead to flaky tests. It is much better to do the have_css shown above

Not able to show committers list in Jenkins Jelly email template

We have recently migrated our jenkins to 1.6 version and I have findbug project set. While showing findbug results in email using below jelly template, "Find Bugs warnings info" section shows error message as "Find Bugs Publisher did not get invoked due to an error". But I do not see any error in console.
Also, "New Warnings" section is not showing up. It looks that fb variable is null and no results are showing up in email template.
Even the change sets section is not visible.
Is there any setting missing for findbug in Jenkins required to show up these results.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<html>
<head>
<title>${project.name}</title>
<style>
body table, td, th, p, h1, h2 {
margin:0;
font:normal normal
90% Georgia, Serif;
background-color: #ffffff;
}
h1, h2 {
border-bottom:dotted 1px #999999;
padding:5px;
margin-top:10px;
margin-bottom:10px;
color: #000000;
font: normal bold 90%
Georgia,Serif;
background-color:#f0f0f0;
}
</style>
</head>
<body>
<div class="header">
<j:set var="spc" value="&nbsp;&nbsp;" />
<h1>
<j:choose>
<j:when test="${build.result=='SUCCESS'}">
<img src="${rooturl}static/e59dfe28/images/32x32/blue.gif" />
</j:when>
<j:when test="${build.result=='FAILURE'}">
<img src="${rooturl}static/e59dfe28/images/32x32/red.gif" />
</j:when>
<j:otherwise>
<img
src="${rooturl}static/e59dfe28/images/32x32/yellow.gif" />
</j:otherwise>
</j:choose>
BUILD ${build.result}
</h1>
<table>
<tr>
<td>Build URL</td>
<td>
${rooturl}${build.url}
</td>
</tr>
<tr>
<td>Project:</td>
<td>${project.name}</td>
</tr>
<tr>
<td>Date of build:</td>
<td>${it.timestampString}</td>
</tr>
<tr>
<td>Build duration:</td>
<td>${build.durationString}</td>
</tr>
<tr>
<td>Build cause:</td>
<td>
<j:forEach var="cause" items="${build.causes}">${cause.shortDescription}
</j:forEach>
</td>
</tr>
<tr>
<td>Build description:</td>
<td>${build.description}</td>
</tr>
<tr>
<td>Built on:</td>
<td>
<j:choose>
<j:when test="${build.builtOnStr!=''}">${build.builtOnStr}
</j:when>
<j:otherwise>master</j:otherwise>
</j:choose>
</td>
</tr>
</table>
</div>
<!-- Static Analysis -->
<j:set var="actions" value="${it.staticAnalysisActions}" />
<j:if test="${!actions.isEmpty()}">
<div class="content">
<h1>Static Analysis Results</h1>
<table>
<tr>
<th></th>
<th>Name</th>
<th>Result</th>
<th>Total</th>
<th>High</th>
<th>Normal</th>
<th>Low</th>
</tr>
<j:forEach var="action" items="${actions}">
<tr>
<td>
<img src="${rooturl}${action.smallImageName}" />
</td>
<td>
<a href="${rooturl}${build.url}/${action.urlName}">${action.displayName}
</a>
</td>
<td class="center">
<j:choose>
<j:when test="${action.result.pluginResult=='SUCCESS'}">
<img src="${rooturl}static/e59dfe28/images/16x16/blue.gif" />
</j:when>
<j:when test="${action.result.pluginResult=='FAILURE'}">
<img src="${rooturl}static/e59dfe28/images/16x16/red.gif" />
</j:when>
<j:otherwise>
<img src="${rooturl}static/e59dfe28/images/16x16/yellow.gif" />
</j:otherwise>
</j:choose>
</td>
<td class="center">${action.result.numberOfAnnotations}
</td>
<td class="center">${action.result.getNumberOfAnnotations('HIGH')}
</td>
<td class="center">${action.result.getNumberOfAnnotations('NORMAL')}
</td>
<td class="center">${action.result.getNumberOfAnnotations('LOW')}
</td>
</tr>
</j:forEach>
</table>
</div>
</j:if>
<!-- More Find bugs info-->
<j:set var="fb" value="${it.getAction('hudson.plugins.findbugs.FindBugsResultAction')}" />
<div class="content">
<h1>Find Bugs warnings info</h1>
<table width="100%">
<tr>
<th>Total</th>
<th>Fixed</th>
<th>New</th>
<th >Report</th>
</tr>
<tr>
<td class="center">${fb.result.numberOfWarnings}</td>
<td class="center">${fb.result.numberOfFixedWarnings}</td>
<td class="center">${fb.result.numberOfNewWarnings}</td>
<td class="center">View Report</td>
</tr>
</table>
</div>
<j:set var="newWarnings" value="${fb.result.newWarnings}" />
<j:if test="${newWarnings!=null}">
<div class="content">
<h1>New warnings</h1>
<table width="100%" class="newWarningsborder">
<tr>
<th width="20%" class="newWarningsborder">Name</th>
<th width="5%" class="newWarningsborder">Line</th>
<th width="*" class="newWarningsborder">Message</th>
</tr>
<j:forEach var="fileAnnotation" items="${newWarnings}" varStatus="loop">
<tr>
<td width="20%" class="newWarningsborder">${fileAnnotation.shortFileName}</td>
<td width="5%" class="newWarningsborder">${fileAnnotation.primaryLineNumber}</td>
<td width="*" class="newWarningsborder">${fileAnnotation.message}</td>
</tr>
</j:forEach>
</table>
</div>
</j:if>
<!-- CHANGE SET -->
<div class="content">
<j:set var="changeSet" value="${build.changeSet}" />
<j:if test="${changeSet!=null}">
<j:set var="hadChanges" value="false" />
<a href="${rooturl}${build.url}/changes">
<h1>Changes</h1>
</a>
<j:forEach var="cs" items="${changeSet.logs}" varStatus="loop">
<j:set var="hadChanges" value="true" />
<h2>${cs.msgAnnotated}</h2>
<p>
by
<em>${cs.author}</em>
</p>
<table>
<j:forEach var="p" items="${cs.affectedFiles}">
<tr>
<td width="10%">${spc}${p.editType.name}</td>
<td>
<tt>${p.path}</tt>
</td>
</tr>
</j:forEach>
</table>
</j:forEach>
<j:if test="${!hadChanges}">
<p>No Changes</p>
</j:if>
<br />
</j:if>
</div>
<!-- ARTIFACTS -->
<j:set var="artifacts" value="${build.artifacts}" />
<j:if test="${artifacts!=null and artifacts.size()>0}">
<div class="content">
<h1>Build Artifacts</h1>
<ul>
<j:forEach var="f" items="${artifacts}">
<li>
${f}
</li>
</j:forEach>
</ul>
</div>
</j:if>
<!-- MAVEN ARTIFACTS -->
<j:set var="mbuilds" value="${build.moduleBuilds}" />
<j:if test="${mbuilds!=null}">
<div class="content">
<h1>Build Artifacts</h1>
<j:forEach var="m" items="${mbuilds}">
<h2>${m.key.displayName}</h2>
<j:forEach var="mvnbld" items="${m.value}">
<j:set var="artifacts" value="${mvnbld.artifacts}" />
<j:if test="${artifacts!=null and artifacts.size()>0}">
<ul>
<j:forEach var="f" items="${artifacts}">
<li>
${f}
</li>
</j:forEach>
</ul>
</j:if>
</j:forEach>
</j:forEach>
<br />
</div>
</j:if>
</body>
</html>

How to display subversion URL for the Project with jenkins email-ext plugin?

Here is the jelly script i am using:
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<STYLE>BODY, TABLE, TD, TH, P { font-family:Verdana,Helvetica,sans serif; font-size:11px; color:black; } h1 { color:black; } h2 { color:black; } h3 {
color:black; } TD.bg1 { color:white; background-color:#0000C0; font-size:120% } TD.bg2 { color:white;
background-color:#4040FF; font-size:110% } TD.bg3 { color:white; background-color:#8080FF; } TD.test_passed { color:blue; } TD.test_failed { color:red
; } TD.console { font-family:Courier New; }</STYLE>
<BODY>
<j:set var="spc" value="&nbsp;&nbsp;" />
<!-- GENERAL INFO -->
<TABLE>
<TR>
<TD align="right">
<j:choose>
<j:when test="${build.result=='SUCCESS'}">
<IMG SRC="${rooturl}static/e59dfe28/images/32x32/blue.gif" />
</j:when>
<j:when test="${build.result=='FAILURE'}">
<IMG SRC="${rooturl}static/e59dfe28/images/32x32/red.gif" />
</j:when>
<j:otherwise>
<IMG SRC="${rooturl}static/e59dfe28/images/32x32/yellow.gif" />
</j:otherwise>
</j:choose>
</TD>
<TD valign="center">
<B style="font-size: 200%;">BUILD ${build.result}</B>
</TD>
</TR>
<TR>
<TD>Build URL</TD>
<TD>
${rooturl}${build.url}
</TD>
</TR>
<TR>
<TD>Project:</TD>
<TD>${project.name}</TD>
</TR>
<TR>
<TD>Date of build:</TD>
<TD>${it.timestampString}</TD>
</TR>
<TR>
<TD>Build duration:</TD>
<TD>${build.durationString}</TD>
</TR>
<TR>
<!-- BRANCH -->
<TD>Subversion Repo:</TD>
<TD>${build.scm}</TD>
</TR>
<tr>
<td>Build Cause:</td>
<td>
<j:forEach var="cause" items="${build.causes}">${cause.shortDescription} </j:forEach>
</td>
</tr>
</TABLE>
<BR />
<!-- CHANGE SET -->
<j:set var="changeSet" value="${build.changeSet}" />
<j:if test="${changeSet!=null}">
<j:set var="hadChanges" value="false" />
<TABLE width="100%">
<TR>
<TD class="bg1" colspan="2">
<B>CHANGES</B>
</TD>
</TR>
<j:forEach var="cs" items="${changeSet}" varStatus="loop">
<j:set var="hadChanges" value="true" />
<j:set var="aUser" value="${cs.hudsonUser}" />
<TR>
<TD colspan="2" class="bg2">${spc}Revision
<B>${cs.commitId?:cs.revision?:cs.changeNumber}</B>by
<B>${aUser!=null?aUser.displayName:cs.author.displayName}:</B>
<B>(${cs.msgAnnotated})</B></TD>
</TR>
<j:forEach var="p" items="${cs.affectedFiles}">
<TR>
<TD width="10%">${spc}${p.editType.name}</TD>
<TD>${p.path}</TD>
</TR>
</j:forEach>
</j:forEach>
<j:if test="${!hadChanges}">
<TR>
<TD colspan="2">No Changes</TD>
</TR>
</j:if>
</TABLE>
<BR />
</j:if>
<!-- ARTIFACTS -->
<j:set var="artifacts" value="${build.artifacts}" />
<j:if test="${artifacts!=null and artifacts.size()>0}">
<TABLE width="100%">
<TR>
<TD class="bg1">
<B>BUILD ATRIFACTS</B>
</TD>
</TR>
<TR>
<TD>
<j:forEach var="f" items="${artifacts}">
<li>
${f}
</li>
</j:forEach>
</TD>
</TR>
</TABLE>
<BR />
</j:if>
<!-- MAVEN ARTIFACTS -->
<j:set var="mbuilds" value="${build.moduleBuilds}" />
<j:if test="${mbuilds!=null}">
<TABLE width="100%">
<TR>
<TD class="bg1">
<B>BUILD ATRIFACTS</B>
</TD>
</TR>
<j:forEach var="m" items="${mbuilds}">
<TR>
<TD class="bg2">
<B>${m.key.displayName}</B>
</TD>
</TR>
<j:forEach var="mvnbld" items="${m.value}">
<j:set var="artifacts" value="${mvnbld.artifacts}" />
<j:if test="${artifacts!=null and artifacts.size()>0}">
<TR>
<TD>
<j:forEach var="f" items="${artifacts}">
<li>
${f}
</li>
</j:forEach>
</TD>
</TR>
</j:if>
</j:forEach>
</j:forEach>
</TABLE>
<BR />
</j:if>
<!-- JUnit TEMPLATE -->
<j:set var="junitResultList" value="${it.JUnitTestResult}" />
<j:if test="${junitResultList.isEmpty()!=true}">
<TABLE width="100%">
<TR>
<TD class="bg1" colspan="2">
<B>${project.name} Functional Tests</B>
</TD>
</TR>
<j:forEach var="junitResult" items="${it.JUnitTestResult}">
<j:forEach var="packageResult" items="${junitResult.getChildren()}">
<TR>
<TD class="bg2" colspan="2">Name: ${packageResult.getName()} Failed: ${packageResult.getFailCount()} test(s), Passed: ${packageResult.getP
assCount()} test(s), Skipped: ${packageResult.getSkipCount()} test(s), Total:
${packageResult.getPassCount()+packageResult.getFailCount()+packageResult.getSkipCount()} test(s)</TD>
</TR>
<j:forEach var="failed_test" items="${packageResult.getFailedTests()}">
<TR bgcolor="white">
<TD class="test_failed" colspan="2">
<B>
<li>Failed: ${failed_test.getFullName()}
<br />
<pre>
${failed_test.errorDetails}
</pre></li>
</B>
</TD>
</TR>
<TR bgcolor="white">
<TD class="test_failed" colspan="2">
<B>
<li>StackTrace: ${failed_test.getFullName()}
<br />
<pre>
${failed_test.errorStackTrace}
</pre></li>
</B>
</TD>
</TR>
</j:forEach>
</j:forEach>
</j:forEach>
</TABLE>
<BR />
</j:if>
<!-- COBERTURA TEMPLATE -->
<j:set var="coberturaAction" value="${it.coberturaAction}" />
<j:if test="${coberturaAction!=null}">
<j:set var="coberturaResult" value="${coberturaAction.result}" />
<j:if test="${coberturaResult!=null}">
<table width="100%">
<TD class="bg1" colspan="2">
<B>Cobertura Report</B>
</TD>
</table>
<table width="100%">
<TD class="bg2" colspan="2">
<B>Project Coverage Summary</B>
</TD>
</table>
<table border="1px" class="pane">
<tr>
<td>Name</td>
<j:forEach var="metric" items="${coberturaResult.metrics}">
<td>${metric.name}</td>
</j:forEach>
</tr>
<tr>
<td>${coberturaResult.name}</td>
<j:forEach var="metric" items="${coberturaResult.metrics}">
<td data="${coberturaResult.getCoverage(metric).percentageFloat}">${coberturaResult.getCoverage(metric).percentage}% (${coberturaResult.ge
tCoverage(metric)})</td>
</j:forEach>
</tr>
</table>
<j:if test="${coberturaResult.sourceCodeLevel}">
<h2>Source</h2>
<j:choose>
<j:when test="${coberturaResult.sourceFileAvailable}">
<div style="overflow-x:scroll;">
<table class="source">
<thead>
<tr>
<th colspan="3">${coberturaResult.relativeSourcePath}</th>
</tr>
</thead>${coberturaResult.sourceFileContent}</table>
</div>
</j:when>
<j:otherwise>
<p>
<i>Source code is unavailable</i>
</p>
</j:otherwise>
</j:choose>
</j:if>
<j:forEach var="element" items="${coberturaResult.childElements}">
<j:set var="childMetrics" value="${coberturaResult.getChildMetrics(element)}" />
<table width="100%">
<TD class="bg2" colspan="2">Coverage Breakdown by ${element.displayName}</TD>
</table>
<table border="1px" class="pane sortable">
<tr>
<td>Name</td>
<j:forEach var="metric" items="${childMetrics}">
<td>${metric.name}</td>
</j:forEach>
</tr>
<j:forEach var="c" items="${coberturaResult.children}">
<j:set var="child" value="${coberturaResult.getChild(c)}" />
<tr>
<td>${child.xmlTransform(child.name)}</td>
<j:forEach var="metric" items="${childMetrics}">
<j:set var="childResult" value="${child.getCoverage(metric)}" />
<j:choose>
<j:when test="${childResult!=null}">
<td data="${childResult.percentageFloat}">${childResult.percentage}% (${childResult})</td>
</j:when>
<j:otherwise>
<td data="101">N/A</td>
</j:otherwise>
</j:choose>
</j:forEach>
</tr>
</j:forEach>
</table>
</j:forEach>
</j:if>
<BR />
</j:if>
<!-- HEALTH TEMPLATE -->
<div class="content">
<j:set var="healthIconSize" value="16x16" />
<j:set var="healthReports" value="${project.buildHealthReports}" />
<j:if test="${healthReports!=null}">
<h1>Health Report</h1>
<table>
<tr>
<th>W</th>
<th>Description</th>
<th>Score</th>
</tr>
<j:forEach var="healthReport" items="${healthReports}">
<tr>
<td>
<img src="${rooturl}${healthReport.getIconUrl(healthIconSize)}" />
</td>
<td>${healthReport.description}</td>
<td>${healthReport.score}</td>
</tr>
</j:forEach>
</table>
<br />
</j:if>
</div>
<!-- CONSOLE OUTPUT -->
<j:getStatic var="resultFailure" field="FAILURE" className="hudson.model.Result" />
<j:if test="${build.result==resultFailure}">
<TABLE width="100%" cellpadding="0" cellspacing="0">
<TR>
<TD class="bg1">
<B>CONSOLE OUTPUT</B>
</TD>
</TR>
<j:forEach var="line" items="${build.getLog(100)}">
<TR>
<TD class="console">${line}</TD>
</TR>
</j:forEach>
</TABLE>
<BR />
</j:if>
</BODY>
</j:jelly>
<!-- BRANCH -->
<TD>Subversion Repo:</TD>
<TD>${build.scm}</TD>
</TR>
does not work, and i am not sure which argument to use with build object to get subversion url.
outside jelly script, i can get the Subversion URL, using:
Subversion URL: ${ENV, var="SVN_URL"}
This might work -
<j:set var="buildenv" value="${build.getEnvironment(listener)}"/>
<j:set var="myvar" value="${buildenv.get('SVN_URL')}"/>
Reference: Jelly script for ext-email plugin jenkins
<TD>${build.envVars.SVN_URL}</TD>

unable to select node in nokogiri with css attribute containing two colons

I'm receiving an error when trying to select a node with css value of "WhoIsOnDutyTableLevel1:header:2" using nokogiri. I'm assuming nokogiri just can't handle two colons. What are my options? I can't change the structure of the html.
Here's the html:
<html lang="en"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="stylesheet" type="text/css" href="stylesheets/forms.css">
<style type="text/css" media="screen" title="AlarmPoint">
#import "stylesheets/AlarmPoint.css";
</style>
</head>
<body><table id="WhoIsOnDutyTableLevel1" class="duty-report-level1">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1" class="duty-report-lt-header">Who's on duty for:
January 06, 2012 00:00 -0800</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1">
<table id="WhoIsOnDutyTableLevel2" class="duty-report-level2">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1">Group Name</th><th id="WhoIsOnDutyTableLevel1:header:2">Group Time Zone</th><th id="WhoIsOnDutyTableLevel1:header:3">Default Devices</th><th id="WhoIsOnDutyTableLevel1:header:4">Supervisors</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="Support" href="/alarmpoint/GroupDetails.do;jsessionid=7pj06dj6krfs?_data=TJZuNquzHUiPj8lqyud7XvypLHHjUnT5bHn7hwtTf9Ei0C2PJ8QYcKIy8OkorCWT8HDTAzkon1ls%0D%0AefuHC1N%2F0SLQLY8nxBhwesdd7Zeg6NzvCfuzRqLg5g%3D%3D" name="Support" class="details">Support</a></td><td headers="WhoIsOnDutyTableLevel1:header:2" class="centered-text">US/Pacific</td><td headers="WhoIsOnDutyTableLevel1:header:3" class="centered-text"><img border="0" src="/static/images/icon_boolean_false.png" alt="No"></td><td headers="WhoIsOnDutyTableLevel1:header:4">
<values>
</values><a id="mgr1" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z4qZ%2FFdHH4hUAixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="mgr1" class="details">Manager 1</a>
</td>
</tr>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1" colspan="4" class="no-padding">
<table id="WhoIsOnDutyTableLevel3" class="duty-report-level3">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1" class="th-left">Blah_Blah1</th><th id="WhoIsOnDutyTableLevel1:header:2" class="">08:00 - 17:00 TU WE TH FR </th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1" colspan="2" class="no-padding">
<table id="WhoIsOnDutyTableLevel4" class="duty-report-level4">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1">Recipient</th><th id="WhoIsOnDutyTableLevel1:header:2">Category</th><th id="WhoIsOnDutyTableLevel1:header:3">Escalation</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr id="205414">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user0" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z6oL%2BaI47zI4gixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user0" class="details">User 0</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">0</td>
</tr>
<tr id="207569">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user1" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z4qZ%2FFdHH4hUAixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user1" class="details">User 1</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">10</td>
</tr>
<tr id="209107">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user2" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z6uKpyoDh%2Fz%2FQixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="uer2" class="details">User 2</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">25</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1" colspan="4" class="no-padding">
<table id="WhoIsOnDutyTableLevel3" class="duty-report-level3">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1" class="th-left">Blah_Blah</th><th id="WhoIsOnDutyTableLevel1:header:2" class="">17:00 Lasting 15:00 WE TH FR </th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr>
<td headers="WhoIsOnDutyTableLevel1:header:1" colspan="2" class="no-padding">
<table id="WhoIsOnDutyTableLevel4" class="duty-report-level4">
<caption></caption>
<thead>
<tr>
<th id="WhoIsOnDutyTableLevel1:header:1">Recipient</th><th id="WhoIsOnDutyTableLevel1:header:2">Category</th><th id="WhoIsOnDutyTableLevel1:header:3">Escalation</th>
</tr>
</thead>
<tfoot></tfoot>
<tbody>
<tr id="210855">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user0" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z72pjQodq7P5gixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user0" class="details">User 0</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">5</td>
</tr>
<tr id="210529">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user1" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z6r1%2Fmnw2SZ2AixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user1" class="details">User 1</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">10</td>
</tr>
<tr id="210337">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user2" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z6Rwqu8vCtzBAixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user2" class="details">User 2</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">15</td>
</tr>
<tr id="204675">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user3" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z5oj5jdRJbzggixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user3" class="details">User 3</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">20</td>
</tr>
<tr id="205555">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user4" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z4G8e7%2FY9SHyQixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user4" class="details">User 4</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">25</td>
</tr>
<tr id="205004">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user5" href="/alarmpoint/UserDevices.do;jsessionid=7pj06dj6krfs?_data=KpBkJeR08z5XHkcVAMfXqgixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D" name="user5" class="details">User 5</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">PERSON</td><td headers="WhoIsOnDutyTableLevel1:header:3">30</td>
</tr>
<tr id="204718">
<td headers="WhoIsOnDutyTableLevel1:header:1"><a id="user6" href="/alarmpoint/GroupDetails.do;jsessionid=7pj06dj6krfs?_data=TJZuNquzHUiUNEK29yovHscXndexl2jCbHn7hwtTf9Ei0C2PJ8QYcKIy8OkorCWT8HDTAzkon1ls%0D%0AefuHC1N%2F0SLQLY8nxBhwesdd7Zeg6NzvCfuzRqLg5g%3D%3D" name="user6" class="details">User 6</a></td><td headers="WhoIsOnDutyTableLevel1:header:2">GROUP</td><td headers="WhoIsOnDutyTableLevel1:header:3">35</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body></html>
I'm running this in my rails console:
>> onDuty_userList = doc.at_xpath('//*[#id="WhoIsOnDutyTableLevel4"]/tbody/tr')
=> #<Nokogiri::XML::Element:0x1b83804 name="tr" attributes=[#<Nokogiri::XML::Attr:0x1b83764 name="id" value="208894">] children=[#<Nokogiri::XML::Element:0x1b83174 name="td" attributes=[#<Nokogiri::XML::Attr:0x1b83110 name="headers" value="WhoIsOnDutyTableLevel1:header:1">] children=[#<Nokogiri::XML::Element:0x1b82b70 name="a" attributes=[#<Nokogiri::XML::Attr:0x1b82aa8 name="href" value="/alarmpoint/UserDevices.do;jsessionid=3pz7t91kle3?_data=KpBkJeR08z6mdgIY4sPrzAixAYz%2BqH6ZPkanPQ24VqQFpjRFPQiWigQHttJBTMFaCLEBjP6ofpk%2B%0D%0ARqc9DbhWpI1nHAqm8ex%2BxOmu7xYUNxRSU0XUo1xoRw%3D%3D">, #<Nokogiri::XML::Attr:0x1b82a94 name="name" value="xxx">, #<Nokogiri::XML::Attr:0x1b82a80 name="id" value="xxx">, #<Nokogiri::XML::Attr:0x1b82a6c name="class" value="details">] children=[#<Nokogiri::XML::Text:0x1b7b438 "\r\n xxx, xxx (xxx)\r\n ">]>]>, #<Nokogiri::XML::Element:0x1b7b104 name="td" attributes=[#<Nokogiri::XML::Attr:0x1b7b0a0 name="headers" value="WhoIsOnDutyTableLevel1:header:2">] children=[#<Nokogiri::XML::Text:0x1b7aba0 "PERSON">]>, #<Nokogiri::XML::Element:0x1b7a984 name="td" attributes=[#<Nokogiri::XML::Attr:0x1b7a90c name="headers" value="WhoIsOnDutyTableLevel1:header:3">] children=[#<Nokogiri::XML::Text:0x1b7a420 "0">]>, #<Nokogiri::XML::Text:0x1b7a1f0 "\r\n">]>
When I try to select with css value:
>> onDuty_userList.css('WhoIsOnDutyTableLevel1:header:2')
Nokogiri::CSS::SyntaxError: unexpected '2' after ':'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:87:in `on_error'
from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/racc/parser.rb:99:in `_racc_do_parse_c'
from /home/dan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/racc/parser.rb:99:in `do_parse'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:62:in `parse'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/css/parser_extras.rb:79:in `xpath_for'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/css.rb:23:in `xpath_for'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:211:in `block in css'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:210:in `map'
from /home/dan/.rvm/gems/ruby-1.9.2-p290#apraper/gems/nokogiri-1.5.0/lib/nokogiri/xml/node.rb:210:in `css'
from (irb):129
from /home/dan/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
You need to preface the id with a #.
This should work:
doc.css('#WhoIsOnDutyTableLevel1:header:2')

TCPDF, php variable values do not appear on the saved pdf file

I created a pdf using TCPDF and I filled it with some php variables and the current date using heredoc syntax
Everything is fine when the pdf is generated and viewed in the browser, but on the saved pdf file the php variable values are not shown, only the date...
I declare my variables at the top like so:
$name = $_POST['name'];
$score = $_POST['percentage'];
$ku_number = $_POST['ku-number'];
$date = Date('d - m - Y');
Only $date is shown on the saved pdf.
Any suggestion?
Thank you
Edit: code to pass the variables to TCPDF
// Print a text
$html = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
table{
text-align:center;
color:#000;
}
</style>
<table id="name" cellpadding="0">
<tr>
<td width="10" height="80"> </td>
<td width="620"> </td>
<td width="10"> </td>
</tr>
<tr>
<td> </td>
<td width="620">$name</td>
<td> </td>
</tr>
<tr>
<td width="10"> </td>
<td> </td>
<td width="10"> </td>
</tr>
</table>
<table id="score" cellpadding="0" >
<tr>
<td width="10" height="180"> </td>
<td width="620"> </td>
<td width="10"> </td>
</tr>
<tr>
<td> </td>
<td width="620">$score</td>
<td> </td>
</tr>
<tr>
<td width="10" height="207"> </td>
<td> </td>
<td width="10"> </td>
</tr>
</table>
<table id="ku-number" cellpadding="0" >
<tr height="2">
<td width="50" height="2"></td>
<td width="620" height="2"></td>
<td width="10" height="2"></td>
</tr>
<tr>
<td> </td>
<td width="620" height="20"></td>
<td> </td>
</tr>
<tr>
<td width="50"> </td>
<td>$ku_number</td>
<td > </td>
</tr>
</table>
<table id="date" cellpadding="0" >
<tr height="2">
<td width="50" height="2"></td>
<td width="620" height="2"></td>
<td width="10" height="2"></td>
</tr>
<tr>
<td> </td>
<td width="420" height="20">$date</td>
<td> </td>
</tr>
<tr>
<td width="50"> </td>
<td></td>
<td > </td>
</tr>
</table>
EOF;
$pdf->writeHTML($html, true, false, true, false, '');
//Close and output PDF document
$pdf->Output('certificate.pdf', 'I');
I had the same problem. I found a solution by experimenting things myself mentioned as follows:
Please use concatenation to break $html string into parts. This will surely solve the problem. e.g. I used something like this:
$html = 'HTML CONTENT BREAKS HERE' . $variable_name . 'HTML CONTENT CONTINUES HERE' ;
Normally, most developers will use PHP variable within $html value,
$html = 'HTML CONTENT echo php variable HTML CONTENT' ;
I hope this will work.
Using $_SESSION to store the variables before outputting the PDF solved the problem
Credits go to Yuri Stuken
For more refined results:
Outputting the final PDF:
When you’ve finished creating all required cells, images, links, text etc. you have to call the Output() method to actually get your hands on your dynamically created PDF. This can take no parameters in which case the PDF is sent to the browser, more commonly though, developers specify the filename and the destination of the generated PDF. The destination can be one of four values, these are:
I: send the file inline to the browser.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name.
S: return the document as a string.
You can see my code sets the destination value as F:
$pdf->Output(”./pdfs/example.pdf”, “F”);
referenced from:this
Have a bAlaNCeD Life !

Resources