We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Save pdf to serverside using PDFviewer

Hello ,  I am working in a ASP.NET core 2.2 web form using PDF viewer  , and i want to save the File that i loaded on viewer to server side .

3 Replies

AA Akshaya Arivoli Syncfusion Team December 17, 2019 03:57 AM

Hi Nguyen, 

Thank you for contacting Syncfusion support. 

We can save the PDF document in the server side in the Download() web action method of the PDF Viewer server library. Please find the code snippet for the same from the below, 

Code snippet: 
public IActionResult Download([FromBody] Dictionary<string, string> jsonObject) 
            PdfRenderer pdfviewer = new PdfRenderer(_cache);           
            string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); 
            string base64String = documentBase.Split(new string[] { "data:application/pdf;base64," }, StringSplitOptions.None)[1]; 
            if (base64String != null || base64String != string.Empty) 
                byte[] byteArray = Convert.FromBase64String(base64String);                
                System.IO.File.WriteAllBytes(_hostingEnvironment.WebRootPath + "\\output.pdf", byteArray); 
            return Content(string.Empty); 

We have created the sample for the same and shared in the following location, 

In the above sample clicking on the download icon in the default toolbar will save the PDF document in the server. 

Please try this and revert us with more details if you have any concerns on this. 


NG Nguyen Gia Huy December 17, 2019 04:13 AM

Thank you very much  for your reply, i saved the pdf file to server side .

AA Akshaya Arivoli Syncfusion Team December 18, 2019 12:28 AM

Hi Nguyen, 

Thank you for your update. We are glad to hear that your requirement is achieved. 


Live Chat Icon For mobile
Up arrow icon