How can I save a pdf file to a specific server location using PDFViewer???
The threads that I found aren't really that helpful when it comes to this particular issue. Can someone please give me an explanation to make this possible.
To be more specific, I'd like to save the original file name from clienr-side to a specific server location. I'm struggling to get that file name.
Hi Farai,
In the given sample, the document is saved in the server location with the same file name at the client side.
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); MemoryStream ms = new MemoryStream(byteArray); var path = _hostingEnvironment.ContentRootPath; System.IO.File.WriteAllBytes(path + $"/{jsonObject["documentId"]}", byteArray); } return Content(String.Empty); } |
Steps to save the PDF in the server location:
Please let us know if you have any concerns on this.
Regards,
CCM Karthik
Thank you, CCM Karthik. It works.
Is there a way I can use my own custom button to accomplish the same results? And also, is there a way I can get the document's original path?
Hi Farai,
Kindly find the details for the respective queries.
Is there a way I can use my own custom button to accomplish the same results?
|
Kindly refer the below sample to save the document in the server with a button click.
Steps to save the PDF in the server location:
|
is there a way I can get the document's original path?
|
It is not possible to get the document's original path while loading the document. |
Please let us know if you have any concerns on this.
Regards,
CCM Karthik
Thanks you good sir. I will get back to you
Thank you, CCM Karthik. Works perfectly.
Hi Farai,
Thanks for the update. We are closing this ticket now, Kindly re-open this ticket, if you have any concerns on this.
Regards,
CCM Karthik