Pdf Viewer in webassembly using stream

Hello,

I want to use pdf viewer using stream source that i fetch from my web api. 

I cant find any help so far for this problem. Please help

1 Reply 1 reply marked as answer

DM Dhivyabharathi Mohan Syncfusion Team January 12, 2021 12:57 PM UTC

Hi Indra, 
 
Thanks for contacting Syncfusion support.  
 
In our PDF Viewer, We can load the PDF document by using the document path or base 64 string and retrieve the document details as stream in the load API . We have shared the controller code for load the document in PDF Viewer. Can you please  let us know the exact requirement and code snippet, whether you want to load the document as stream in the load API. 
 
Controller code for load the document: 
 
public IActionResult Load([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            MemoryStream stream = new MemoryStream(); 
            object jsonResult = new object(); 
            if (jsonObject != null && jsonObject.ContainsKey("document")) 
            { 
                if (bool.Parse(jsonObject["isFileName"])) 
                { 
                    string documentPath = GetDocumentPath(jsonObject["document"]); 
                    if (!string.IsNullOrEmpty(documentPath)) 
                    { 
                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath); 
                        stream = new MemoryStream(bytes); 
                    } 
                    else 
                    { 
                        return this.Content(jsonObject["document"] + " is not found"); 
                    } 
                } 
                else 
                { 
                   byte[] bytes = Convert.FromBase64String(jsonObject["document"]); 
                    stream = new MemoryStream(bytes); 
                } 
            } 
            jsonResult = pdfviewer.Load(stream, jsonObject); 
            return Content(JsonConvert.SerializeObject(jsonResult)); 
        } 
 
  
Regards, 
Dhivya. 


Marked as answer
Loader.
Up arrow icon