Articles in this section
Category / Section

Saving the PDF document in the server side using PDF viewer control

1 min read


You can save the form fields, signatures, and annotations to the PDF document on the server side of the PDF viewer control using the download() API in the button click. For this, modify the Download web action method in the web API controller of the PDF viewer control. Following is the server-side code snippet for the Download action method of the API controller. 

public object Download(Dictionary<string, string> jsonResult)
            PdfViewerHelper helper = new PdfViewerHelper();
            //Retrieve the JSON object which contains PDF document as base64 string.   
            object json = helper.GetDocumentData(jsonResult);
            //Retrieve the base64 string.  
            string base64String = json.GetType().GetProperty("documentStream").GetValue(json, null).ToString();
            //Save the PDF document in specific location.  
            if (base64String != null || base64String != string.Empty)
                byte[] byteArray = Convert.FromBase64String(base64String);
                System.IO.File.WriteAllBytes(HttpContext.Current.Server.MapPath("~/Output/Sample.pdf"), byteArray);
            return null;


Note: You can create your own web action method in the Web API controller using the severActionSettings API in which you can include the code for saving the PDF document in server side as provided in the code snippet.

Client-side code for saving the PDF document

<div style="padding:5px">
        <button type="button" style="padding:3px;" onclick="savePdfDocument();">Save PDF Document </button>
  function savePdfDocument(args)


In the following sample clicking ‘Save PDF Document’ button and Download icon in the PDF Viewer toolbar will save the PDF document in server side:

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment