Google Chart Image does not load - google-visualization

Im using Google charts to create a QR Code. It produces the QR Code perfectly when i just paste the link directly on the browser. However, i cannot get it to load as an image. I get a 400 Error Response.
i.e.: http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/Test%3Fsecret%3DGVFXGN3WIYZEMYKW
pasted directly in the browser works but how can i get it to show as an image?
What am i doing wrong?
<img src="http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/AEB+Staff+Benefits%3Fsecret%3DGVFXGN3WIYZEMYKW" width="200" height="200" />

You need to URL-encode the /'s (code %2F) in the chl parameter of the URL:
http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth:%2F%2Ftotp%2FTest%3Fsecret%3DGVFXGN3WIYZEMYKW

Related

How to put an image from a local drive into a cfdocument file?

This will show me the image in a browser:
<cfset myImage=ImageNew("d:\UploadedDocuments\thumbnails\1487862_page_1.jpg")>
<cfimage source="#myImage#" action="writeToBrowser">
But if I use the same code inside of a .pdf file, it generates a small red x. Is this not possible to do?
If the image is already on the drive you don't need CFIMAGE here. You can embed it like so:
<img src="file:///d:\mysite\images\myimage.jpg" width="50" height="60">
You could also use an HTTP Path to it as well - store it at a location accessible by your web server through real or virtual directories use the <img> tag like you normally would.
This post on cfdocument and SSL and this suplimental post on using the file system with cfdocument should help you sort it out.

Coldfusion cfhtmltopdf tag not displaying bmp images

I'm using a <cfhtmltopdf> tag to pull in a .cfm file as a template and create a PDF. All works well when I use jpg for the image format. But if the image is a BMP - for some reason it won't work.
In the template file , I'm using a <cfdirectory> tag with no filter to pull in the images.
<cfdirectory directory="E:\xxx\images\#image_ID#\" name="myDir" type="file" sort="datelastmodified">
then I'm using a <cfloop> to display images from the directory...
<cfloop query="myDir">
<cfif right(myDirMain.name,4) is ".bmp" >
<img src="#request.root#images/#images_ID#/#myDir.name#" border="0" width="230px" style="margin-bottom:15px;" />
</cfif>
This works great for jpg, but when trying to use bmp images - it's no good.
Does anyone know if a reason why bmp images are an issue or does only work with jpg images?
There seems to be a bug in the system that stops PDF's using BMP images. A solution is to convert them using <cfimage> tag before creating the PDF - its workaround that works, even thou it uses a little bit more server resources.

cfimage from binary in cfdocument

I am writing a PDF dynamically, and am creating a QR code on the document for eTicketing purposes
i set my cfdocument localurl=yes to include a different image, which works fine, but since I am using an API call to get the binary for the qrCode, the using cfimage to display the image, it is only showing a red X
<cfdocument format="PDF" overwrite="Yes" localUrl="yes" pageType = "letter">
<body>
<cfoutput>
<section id="header">
<img src="file:///#ExpandPath('images/header.png')#"/>
<cfimage action="writeToBrowser" source="#rc.qrCode#" />
</cfoutput>
</body>
</html>
</cfdocument>
the source variable rc.qrCode is a binary response that works perfectly until i place inside cfdocument, it generates a url like this http://mysite/CFFileServlet/_cf_image/_cfimg-7945382145198648283.PNG as image source
i am sure this has todo with localurl and file:///, i just an not knowledgable enough to know why
Do not need to use physical path rather use relative path to your page.
e.g.
If you code in index.cfm of root folder and image inside images folder
try <img src="images/header.png"> , Note that it should not start with root path rather relative to your file.
UPDATE
writetoBrowser internally write file to hard drive to it's temporary location (topically, C:\ColdFusion10\cfusion\tmpCache\CFFileServlet) and while rendering it to browser it use relative path like "/CFFileServlet/_cf_image/_cfimg1592404668342998556.PNG", you can say that ColdFusion internally map CFFileServlet directory with all coldfusion site but notice leading forward slash and this makes issue with localurl=true. Since localurl=true either need physical path or relative path to your document.
Good idea is instead of writetobrowser you can write same image to harddrive at your location and give physical path in img tag. I do not this there will any performance issue since ColdFusion internally doing same thing when you are using writetobrowser attribute :)

dynamic pdf-cfdocument + cfcontent + image + email attachement

How can images be loaded into a dynamically generated pdf (cfdocument)? In that the pdf is not stored the hdd. The pdf needs to be emailed, and the ram cleared. The images are stored outside of the wwwroot folder.
If it is need be, the pdf can get stored in the hdd, get attached, emailed, then deleted, but would opt for it not to get stored in the hdd.
c:\coldFusion9\imgs\ is the dir
Sample:
<cfdocument format="PDF" localurl="true">
<cfoutput> #vars#</cfoutput>
</cfdocument>
I have used
<img src="">
inside cfdocument, and it works if the image is in the wwwroot (http...) folder, but not when the image is outsite the wwwroot ("c:\coldFusion9\imgs#image#.png" or "../imgs/#image#.png").
I suppose that cfcontent is ideal
So, inside cfdocument, I do this:
<cffile action="readbinary" file="c:\coldFusion9\imgs\#image#.png" variable="img">
<cfcontent type="image/jpg" variable="#img#" >
The result is that the image loads, on the screen, not the pdf.
Would like to email the pdf as an email attachement. The pdf does not need to render on screen, but for testing purposes, we could let it render on the screen to know if the image was loaded or not, by either naming or not naming the cfdocument. The pdf renders when the name is removed, it does not render when the name is present.
Appreciate your help.
If i understand your question correctly. You want to
1. Grab an image from a folder outside of your webroot
2. Place image in a cfdocument
3. Attach cfdocument to a cfmail
if that's is the case you need cfimage instead of img and the rest you can find on Ben Nadel's site http://www.bennadel.com/blog/1700-Ask-Ben-Creating-A-PDF-And-Attaching-It-To-An-Email-Using-ColdFusion.htm
or expand on the snippet below.
<cfdocument format="pdf" name="mydoc">
<cfimage action="writeTobrowser" source="c:\temp\test.png" >
</cfdocument>
<cfmail
from="x#y.com"
to="y#x.com"
subject="this is it">
<cfmailparam
file="mydoc.pdf"
type="application/pdf"
content="#mydoc#"/>
</cfmail>
A couple notes to clarify:
cfdocument uses an HTTP connection to grab images, which is why you can't grab any outside the webroot. In my experience, relative paths are problematic, so it's best to use absolute paths. If you want to use images from outside the webroot, you'll need to provide them directly, as in your example or as #KobbyPemson did.
The reason that you don't see the PDF when you add a name is that the name attribute does not name the PDF. It is the name of the variable in which the PDF is stored. So, when you provide it, you are telling CF to stuff the PDF in a variable using the name you supply.

matplotlib svg requires plugin to view

I am trying to dymamically render an SVG image from matplotlib and insert it into the HTML document.
I am using Cairo.SVG as the matplotlib backend.
Now whenever I try to insert it into the
<img src="/url_to_graph" />
//or
<object data="/url_to_graph" />
I either get nothing or the "Missing Plugins" error from Firefox.
FYI I am using Firefox. Also any other examples of SVG images I find on the web, work just fine - and require no plugin.
Does matplotlib render the SVG images in some special format I don't know about?
Have you tried <object type="image/svg+xml" data="/url_to_graph"></object>?
<img src="/url_to_graph"/> should work.
Are you able to see the svg file with other applications?
My guess is that the file is correctly generated, but the webserver is sending them with an incorrect mime-type.