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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Save pdf to serverside using PDFviewer

Thread ID:

Created:

Updated:

Platform:

Replies:

149982 Dec 17,2019 03:18 AM UTC Dec 18,2019 05:28 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: PDF Viewer
Nguyen Gia Huy
Asked On December 17, 2019 03:18 AM UTC

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 .

Akshaya Arivoli [Syncfusion]
Replied On December 17, 2019 08:57 AM UTC

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. 

Regards, 
Akshaya 


Nguyen Gia Huy
Replied On December 17, 2019 09:13 AM UTC

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


Akshaya Arivoli [Syncfusion]
Replied On December 18, 2019 05:28 AM UTC

Hi Nguyen, 

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

Regards, 
Akshaya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon