Hi,
I am faced with a problem. I want to take some
html, pass it to some library and convert it to a
pdf. I'm reading the
html from the frontend, using
jquery, and I want to pass it to a
HttpHandler which converts it and downloads it.The issue is that the html string is too long and I end up with a small portion of that html.
I've tried to pass the html using
ajax,
querystrings and even
cookies, nothing works, do you have any other method of passing a long string of html?
What I have tried:
The way I pass the data in javascript:
var html = $("#gg").html();
var dataToSend = JSON.stringify({'wiki': html});
jQuery.ajax({
contentType: "application/json; charset=utf-8",
url: "FileDownloader.ashx",
dataType: "json",
data: dataToSend,
success: function(msg)
{
alert(msg.d);
},
error: function(type)
{
alert("ERROR!!" + type.responseText);
}
});
The way I read it in the HttpHandler:
public void ProcessRequest(HttpContext context)
{
var html = "";
var value = context.Request["wiki"];
html = HttpUtility.UrlDecode(value, System.Text.Encoding.Default);
IronPdf.PdfDocument pdf = htmlToPdf.RenderHtmlAsPdf(html);
byte[] PdfBinary = pdf.BinaryData;
}