Image is not displaying in cfdocument pdf for coldfusion 10 - pdf

I am using ColdFusion 10 Enterprise edition, and am unable to display images when using CFDOCUMENT to generate a PDF. Below is the piece of code I am using:
<cfsavecontent variable="report">
<table align='center'>
<cfoutput query="VARIABLES.result">
<tr>
<td>
<div class='addInfoDetails'>#SHOWINFO#</div>
</td>
</tr>
</cfoutput>
</table>
</cfsavecontent>
In the above code, the VARIABLES.result query is coming from database and SHOWINFO is a variable having the content of image and text. For example:
SHOWINFO =
"<p> Hi This is the test information
<img alt="image" src="../TestBank/test/info/5KQ.jpg"/>
</p>"
Here if dump the SHOWINFO variable inside the CFSAVECONTENT, the image displays correctly. But when I convert this into PDF, using CFDOCUMENT, the image is not displaying.
Below is the code block I am using to generate the pdf:
<cfdocument format="PDF" saveasname="TestPDF">
<cfoutput>#report#</cfoutput>
</cfdocument>
Thanks in advance.

I fixed it by adding the attribute "localUrl = yes" in CFDOCUMENT tag.
Now it is working fine for me.

I'm saving the created pdf and find localUrl="yes" (or =true) fails. Turns out CF generating pdfs for https urls is painfully finicky.
<img src="file:\\\#replace(getCurrentTemplatePath(),"my.cfm")#images\my.png">
Worked for me, in case anyone is scraping the bottom of the barrel for ideas. getCurrentTemplatePath() gets the filename as well as the path, so I had to remove it (hence the replace(...,"my.cfm"). I also tried expandPath(".") and that failed as well.
Didn't try Dave Anderson's intriguing suggestion to grab the image Coldfusion CFDOCUMENT creates a red X

Related

How to pass ColdFusion cfoutput query row#/ID to another CFM or Function?

I have a Coldfusion project I'm working on and I am displaying a list of announcements that have the details truncated with this type of layout:
AnnouncmentList.cfc
<cfoutput query="qAnnouncements">
<tr>
<Td style="white-space:normal;">
#dateformat(qAnnouncements.Announcement_Send, 'ddd - mm/dd/yyyy')# <BR />
<h4>#qAnnouncements.Announcement_Title#</h4><BR />
#listFirst(wrap(qAnnouncements.Announcement_Content, 100), chr(10))#
...more<BR /><BR />
</Td>
</tr>
</cfoutput>
When I click the "...more" link, I would like a popup to display and show just the content of the announcement that is clicked. I am able to display the correct announcement on the popup by simply adjusting my qAnnouncements query display with a WHERE clause to check the Announcement_ID, but I have to hard code this in at the moment.
So how can I properly pass the qAnnouncements.Announcement_ID of the link that is clicked from the list to my AnnouncementPopup.cfc file to then use for the adjusted query?
Summary: Want to pass Announcement_ID from the in AnnouncementList.cfc -> AnnouncementPopup.cfc

Adding image to HTML/PDF report

I'm trying to add an image in an HTML report template. The image is stored in sys$FileDescriptor. I found some instructions for docx templates, but no luck so far with html templates.
I also tried using FileDescriptor.name as src field, but the file specified doesn't exist
In the end I managed to insert an image in an html template for pdf generation with this code:
<img src="../work/app-core/filestorage/${headerRow.fields.logoYear}/${headerRow.fields.logoMonth}/${headerRow.fields.logoDay}/${headerRow.fields.logoId}.${headerRow.fields.logoExt}" width="220" height="220"/>
The needed fields are obtained in sql from sys_file.update_ts with "to_char" Postgres function to allow for the correct format of the fields (YYYY, MM, DD)
At the moment YARG and CUBA Reporting do not provide means to insert images into HTML-reports similarly to DOCX/XLSX.
But pictures could be inserted/embedded with the img-tag.
src could be a link to picture:
<img src="http://localhost:8080/images/SomePicture.jpg" height="68" width="199" border="0" align="right"/>
Or you can embed a bitmap (your appproach with variables is also useable):
<img alt='SomePicture.png' src='data:image/png;base64,iVBORw0K ..... AcEP9PwxD0hNKK1FCAAAAAElFTkSuQmCC' style='max-width: 100%;'/>
Thank you for your question. The platform documentation is going to be updated soon.

Issue faced in rendering FTL code in <form-list> after updating moqui

After the recent updates in Moqui I am facing a problem in rendering the FTL code using <render-mode> tag.
Let me try to explain the problem,
Earlier I have rendered the FTL code using <render-mode> in <form-list> tag it was working properly but when I took the update of Moqui, it is displaying the whole FTL code written in the tag on browser.
Also after the update of Moqui when I use the same code outside the <form-list>, it is working as expected.
Is this the desired behavior or we should do some changes at framework level.
Below is the sample code for the same.
<form-list name="demoName" list="nameList" >
<field name="name">
<default-field title="Name">
<render-mode>
<text><![CDATA[
<#if name=='Demo Name 1'>
<span class="label label-success">Demo Name 1</span>
<#elseif name=='Demo Name 2'>
<span class="label label-info">Demo Name 2</span>
</#if>
]]></text>
</render-mode>
</default-field>
</field>
</form-list>
This is how the code is being rendered on the screen at revision #891b4d5.
This was the output that we used to get in Moqui revision #983a9e1
Can we use render-mode in form-list the way we are using it in the above code snippet?
For proper usage of the render-mode.text element you should specify a text.#type attribute. It defaults to "all" so the text will be used for all types, but your content contains HTML so it should have text.#type=html.
Still, what you include should work fine. Here is an example from the apps.xml screen in the latest version of Moqui (in the git repo) that runs with every apps screen render and works with interpretation of the inline text as a template:
<render-mode><text type="html"><![CDATA[
<#assign footerItemList = sri.getThemeValues("STRT_FOOTER_ITEM")>
<div id="apps-footer-content">
<#list footerItemList! as footerItem>
${footerItem}
</#list>
</div>
]]></text></render-mode>

SSI tag inside html form?

I have a simple HTML form in which I would like to pre-populate the fields with SSI tag data. This is what I have done:
<form method="get" action="flashWrite.cgi">
<li><i>Network Configuration</i>
<br>
<table border="0">
<tr>
<td>IP Address:</td><td><input value="<!--#ipaddr-->" name="ipaddr"></td>
</tr>
<tr>
<td>Subnet Mask:</td><td><input value="<!--#snetmsk-->" name="snetmsk"></td>
</tr>
<tr>
<td>Gateway:</td><td><input value="<!--#gateway-->" name="gateway"> </td>
</tr></table>
The results are somewhat disapointing:
Never-mind that these IP values are showing up as 32 bit integers, I'll deal with that later. What bothers me is that the tags are showing up in the form. Can someone tell me why in the form, the value is appended to the tag instead of replacing the tag?
This is taking place on a TI LM3S9D96 MCU running an LWIP stack.
If html form code is in firmware, you will create the form as you want.
For example,
In Html:
<td>IP Address:</td><td><!--#form_ipaddr--></td>
In Firmware, code for form_ipaddr tag :
sprintf(pcBuffer, "<input value="%s" name="ipaddr">", pcIpAddrString);
You need to define LWIP_HTTPD_SSI_INCLUDE_TAG 0.
By default the tags are included, helps in debugging.
HTML comment cannot (should not) be placed in another tag as it is a tag itself. And that's it.
But, in this case, it depends on how are you replacing those tags.
in httpd_opts.h :
/** Set this to 0 to not send the SSI tag (default is on, so the tag will
* be sent in the HTML page */
#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG
#define LWIP_HTTPD_SSI_INCLUDE_TAG 0
#endif
set LWIP_HTTPD_SSI_INCLUDE_TAG to 0
In that case the tag will not be sent, but its value will.

Excess Characters Being Generated by ColdFusion Query/output

I've got a strange issue with some Coldfusion/SQL Query output. The actual data is generating properly, but at the bottom of the page it's outputting "Library/Library/Library/Library/Library/Library/Library/Library" for no reason I can discern.
It always outputs it in exactly that format, always 8 times, no matter how many terms I'm searching for, how many records are returned, or how much text is generated after grouping.
It doesn't happen on all pages, but it does seem to happen on every page on the site that pulls a query from this database...
I'm lost. Code below, live page is here: http://www.audiogo-library.com/client/client_pages/hachettepage.cfm
<cfsetting enablecfoutputonly="yes" showdebugoutput="no">
<!--- Custom Hachette page --->
<cfset todayDate = Now()>
<!--- Link to Style Sheets --->
<img style="margin:auto" src="http://www.audiogo-library.com/Library/client/client_images/hachettelogo.gif"></br>
<cfoutput> #MonthAsString(Month(Now()))# </cfoutput> Releases</br></br>
<cfquery name="GetProductBasicInfo" datasource="#Request.Application.PowerWeb.datasource#" dbtype="odbc">
SELECT product.ProductID, productmarket.imprint, product.IsbnUpc, product.Title, product.FullTitle, product.SubTitle, product.PubDate, product.SKU, productmarket.descriptionshort, productmarket.productform, productmarket.NoOfPieces, productmarket.productmarketid
FROM Product, ProductMarket
WHERE product.productid = productmarket.productid AND product.IsbnUpc LIKE '%61113%' AND product.PubDate BETWEEN '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/01/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>' AND '<cfoutput>#DatePart("m", todayDate)#</cfoutput>/31/<cfoutput>#DatePart("yyyy", todayDate)#</cfoutput>'
ORDER BY product.FullTitle ASC
</cfquery>
<cfoutput query="GetProductBasicInfo" Group="FullTitle">
<table width="90%" border="0" style="margin-top:15px;">
<tr>
<td><p><a href="http://www.audiogo-library.com/library/productdetails.cfm?sku=#SKU#">
<cfif #FullTitle# eq ''> <div class="title"> #Title# </div>
<cfelse> <div class="title">#FullTitle# </div> </a>
</cfif></p>
<p>
<cfif #descriptionshort# neq ''> #descriptionshort# </cfif>
</p>
</td>
<td width="30%"> <img src="http://www.audiogo-library.com/library/client/Products/ProdimageLg/#SKU#.jpg"></td>
</tr>
</table>
</cfoutput>
TestText
I actually solved it by accident while trying to push the "/Library"s down the page. It turns out the cfsettings tag built into the query/output was disabling non cfoutput content. THe guy who built the footer was relying on inheriting "enablecfoutputonly='false'", and this code changed that. Everything from the site's footer was being hidden except for the section of each address that was generated by cfoutput. SO yeah, if anyone else has this or a similar problem, check your cfsettings tag, and ensure you DISABLE
Go to cfadmin and disable query caching. Restart the CF service. Voila!...no more extra data.