One possibility, not exactly a clean solution, is to build something on the server which accepts a request of the base-64 and translates it into an image response.
If it's small enough, you can do it all in one big call, and just build an img tag, like:
<img src="MyHandler.ashx?img=784571348589235824...9875290347589243">
But you'll run into issues with URL limits if it's too big. You could also store the base-64 temporarily on the server and make a call to it, assuming your server can handle it. For example, using ASP.NET MVC:
[HttpPost]
public ActionResult GetImageKey(string base64) {
var key = Guid.NewGuid();
HttpContext.Cache.Add(key.ToString(), Convert.FromBase64String(base64), null,
DateTime.Now.AddSeconds(30), Cache.NoSlidingExpiration, CacheItemPriority.Normal,
null);
return Json(new { imageKey = key.ToString() });
}
public ActionResult GetImage(string imageKey) {
return File((byte[])HttpContext.Cache[imageKey], "image/png");
}
function go() {
jQuery.ajax({
url: "/Home/GetImageKey",
type: "post",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'base64':'iVBORw...FNmlZSxpODv+wRj1j56bJnOiwAAAABJRU5ErkJggg=='}",
success: function (result) {
jQuery("#img-result").attr("src", "/Home/GetImage?imageKey=" + result.imageKey);
}
});
}
EDIT Just noticed the question was for PDF, not image, but the same idea should work.