Convert From base 64 to Image In K2 - k2

How do I go about converting a Base64 encoded string to an Image and display on a Picture control in K2?
I tried using a webservice, then on i used something to link and nothing shows up.

I would recommend that you take that Base64 string, create expression (Text, Concatenate from Context browser) where you would compose IMG that should look like this:
<img src='data:image/jpeg;base64, <!-- base64 data -->' />
or in Expression syntax:
Concatenate(<img src='data:image/jpeg;base64,,<!-- base64 data -->,' />)
and in the end, you would create a DataLabel control on your form, enable its Literal property (checkbox in properties) and assign the expression you created above to that DataLabel.

Related

How do I encode an image into a Base64 string within a Macro Scheduler (.scp) macro?

The macro scheduler I am using is the product offered at https://www.mjtnet.com/
My ultimate goal is to have a macro that will send emails with images embedded into it. To do this, I want to be able to convert image files into Base64 strings so that they can be embedded with HTML. The problem that I'm running into is that I cannot figure out how to properly access the data for the image files within Macro Scheduler. I've tried using the file location of the image as an input for the Base64 function, but that only returns the encoded version of the location string. I've also tried using the ReadFile function, but that returns an empty string as it's use is for text files.
Currently my program looks like this:
Let>SENDMAIL_STATUS=1
Let>SMTP_HTMLBODY=1
Let>image=C:\Users\xyz\Documents\image.png
Base64>image,ENCODE,embedded
Let>body=<html> <head> </head> <body> <img src="data:image/png;base64,%embedded%"> </body> </html>
SMTPSendMail>...,...,...,...,...,body,image
The email sends without issue, but the body of it only shows an empty image icon.
So with all this in mind, how do I encode an image file into a base64 string?

How to use unescape() function inside JavaScript?

I have a JSP page in which I have JavaScript function that will be called when a link is clicked. Now, when the value reaches the JavaScript function, the apostrophe is encoded.
Example:
Name#039;s
Before # there is &, which originally should be:
Name's
I have used the unescape() decode function, but nothing seems to work. In the end, I had to delete the characters and add the apostrophe. Does anyone know a fix for this? Is it that JSP doesn't support encoding for &? When I was writing the same encode value in this page, it changed the symbol to the apostrophe, which is what I wanted in my code.
Built-in Javascript function such as unescape(), decodeURIComponent() has nothing to do with the string you are working on, because the one you are looking to decode are HTML entites.
There are no HTML entites decoder available in Javascript, but since you are working with a browser, if the string is considered safe, you may do the following (in JQuery, for example)
var str = $('<p />').html(str).text();
It bascially insert the string as HTML to a <p> element and then extract the text within.
Edit: I just realize the JSP output you posted is not real HTML entities; To process the example given you should use the following, add & before every #1234; and make it Ӓ:
var str = $('<p />').html(str.replace(/\#(\d+)\;/g '&#$1;')).text();

XPath select an image by classname

I have an xml sheet with some data and some images that i want to collect only a part using xslt.
However, there is one image with a particular classname that i would like to collect especially.
For example, the XML says:
<img class="itemImage" height="130" src="image.png" width="195"/>
How do I get the src attribute of this image by selecting it by classname with XPath?
This should work : //img[#class="itemImage"]/#src
This XPath will return the src of the first img node which has a src and has the specified class
(//img[#class="itemImage"]/#src)[1]
However, if you know anything at all about the structure of the xml, you can and should avoid the use of //, which requires the entire document to be scanned.

Safari encodes already encoded URL on request

I do an HTTP GET request for a page using the following URL in Safari:
mysite.com/page.aspx?param=v%e5r
The page contains a form which posts back to itself.
The HTML form tag looks like this when output by asp.net:
<form method="post" action="page.aspx?param=v%u00e5r" id="aspnetForm" >
When Safari POSTs this back it somehow converts this URL to:
page.aspx?param=v%25u00e5r, i.e. it URL encodes the already URL encoded string, which is then double encoded and the output generated by this parameter is garbled (vår). I am able to get around this some places by URL decoding the parameter before printing it.
Firefox and even IE8 handles this fine. Is this a bug in WebKit or am I doing something wrong?
To summarise:
GET mysite.com/page.aspx?param=v%e5r
HTML: <form method="post" action="page.aspx?param=v%u00e5r" id="aspnetForm" >
POST mysite.com/page.aspx?param=v%25u00e5r
HTML: <form method="post" action="page.aspx?param=v%25u00e5r" id="aspnetForm" >
mysite.com/page.aspx?param=v%e5r
Whilst you can use encodings other than UTF-8 in the query part of a URL, it's inadvisable and will generally confuse a variety of scripts that assume UTF-8.
You really want to be producing forms in pages marked as being UTF-8, then accepting UTF-8 in your application and encoding the string vår (assuming that's what you mean) as param=v%C3%A5r.
page.aspx?param=v%u00e5r
Oh dear! That's very much wrong. %uXXXX is a JavaScript-escape()-style sequence only; it is wholly invalid to put in a URL. Safari is presumably trying to fix up the mistake by encoding the % that isn't followed by a two-digit hex sequence with a %25.
Is ASP.NET generating this? If so, that's highly disappointing. How are you creating the <form> tag? If you're encoding the parameter manually, maybe you need to specify an Encoding argument to HttpUtility.UrlEncode? ie. an Encoding.UTF8, or, if you really must have v%e5r, new Encoding(1252) (Windows code page 1252, Western European).

Ignore CDATA while xml parsing

I am new to iphone development.I want to ignore CDATA tag while parsing because it consider the HTML tag following it as text.Since i want to display the content alone ,i want my parser to ignore CDATA tag.My source code is
[CDATA[<br /><p class="author"><span class="by">By: </span>By Sydney Ember</p><br><p>In the week since an </p>]].
Is there any way to ignore CDATA tag?
Is there any way to parse my source twice so it displays only the content?
Please give me some sample code.Please help me out.Thanks.
If you treat the CDATA content as XML instead of CDATA then your parser will throw an error (since your HTML is a weird mix of XHTML and HTML and is not well formed).
If you want to get the HTML, then parse the XML, extract the text content of the node, then parse that text as HTML.
There is no way to ignore the CDATA tag - it's part of the xml spec and parsers should honour it.
If you don't like the idea of this answer to your earlier question, you could get the contents of the CDATA section and parse it as XML again. However, this is highly not recommended! You don't know that the contents of the CDATA are going to be valid xml (they're probably not).
If you can 100% guarentee that the CDATA section contains the form you have above, you could probably use some string manipulation to get the data out (i.e. string replace '<span class="by">By: </span>' with '') but again, this will almost certainly break if the CDATA contents change.
Where is the xml coming from? It's a better idea to talk to owner of the service and get them to send you instead of description something like
<description>
<author>By Sydney Ember</autho>
<text>In the week since an </text>
</description>
S