|
Queries |
Details |
|
I was hoping that I can pass base64 encoded string in the model from my MVC controller. The MVC controller knows how to call a Web Api 2 REST service. The view should not know anything about the service itself. Would it be possible to load PdfViewer from the @model? I don't want the view to do AJAX calls. |
We can pass the base64 string of the PDF document from the MVC controller to the View page and it can loaded in the PDF viewer control using DocumentPath API .
We have created a sample to demonstrate the same. Please find the sample from the following link.
In the above sample, we have provided the text box control and a button in the HTML form element. When the DocumentID is entered in the text box and the View button is clicked, a Form request will be sent to the action method in MVC controller where the byte array of the PDF document will be retrieved from the database and converted into base64 string. This base64 string will be stored in the Model and accessed in the view page then loaded into the PDF viewer control using the DocumentPath API. |
|
I am also having trouble using the example you have supplied in the original reply.
The method load throws exception:
Syncfusion.Pdf.PdfException: 'Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.' |
We are unable to reproduce the reported issue in the sample that we have provided in our previous update. We have recorded the working of the sample as a video for your reference. Please find the screenshot video in the following link.
We suspect that the reported issue may be specific to the PDF document. Please provide the PDF document that you have used to load in the PDF viewer control. It will be helpful for us to analyze further and assist you better. |