asp.net mvc 3 - mvc3 and evopdf - display "processing" message while the pdf is being generated -
i using mvc3 , evopdf (http://www.evopdf.com/) create pdf when user clicks on print button.
i have initial view contains form , print button , 2nd view designed printing.
clicking on print button calls javascript submit form, calls print action.
what happen once print button has been clicked, "processing" message displayed. once pdf has been generated message removed.
this javascript (i have not included of javascript there parts not relevant)
$(document).ready(function () { $(".btn").click(function () { var delay = 10; $("#ajaxdelay").val(delay); $.blockui(); $('#printform').submit(); }); $('#printform').submit(function () { $.blockui(); $.ajax({ url: this.action, type: this.method, success: function (data) { $.unblockui(); //i need open pdf in appropriate app, adobe pdf viewer or similar }, failure:function(data) { alert("error"); $.unblockui(); } }); return false; }); });
the form
@using (html.beginform("printview", "index", new { format = "pdf/", id = model.id, ajaxdelay = model.ajaxdelay }, formmethod.get, new { id="printform" })) { @html.hiddenfor(m=>m.ajaxdelay) <button type="button" class="btn print" >print</button> }
indexcontroller
public actionresult printview(int id) { var model = getdata(id); return view(model); }
this httphandler
public void processrequest(httpcontext context) { if (!context.request.isauthenticated) return; producepdf(context, "pdf title", 20); } private void producepdf(httpcontext context, string title,int delay) { var pdfconverter = getpdfconverter(); // set license key pdfconverter.licensekey = "licence key here"; pdfconverter.javascriptenabled = true; var pdfbytes = pdfconverter.getpdfbytesfromurl(context.request.url.tostring().replace(".pdf/", "")); // send pdf document response browser download var response = httpcontext.current.response; response.clear(); response.addheader("content-type", "application/pdf"); response.addheader("content-disposition", string.format("attachment; filename=" + title + ".pdf; size={0}", pdfbytes.length)); response.binarywrite(pdfbytes); response.end(); }
thanks.
i found solution uses jquery cookie plugin , appending cookie response described in stackoverflow article.
hide image using javascript after controller action complete mvc3
i did have make small change in had specify path when removing cookie.
Comments
Post a Comment