- Home
- Forum
- ASP.NET MVC
- Displaying dynamically created PDF
Displaying dynamically created PDF
Hello,
I've been trying to get the PDF Viewer to display a dynamically created PDF.
Here's what happens:
A user selects some data from a table, on the post back the PDF is generated and the user is returned to the PDFViewer View.
I've looked at many of the PDFViewer solutions on this site and have not found one that works for my situation. The main thing is, the PDF is not stored on the file system or in a database, it's to be created, displayed and destroyed.
My View has this creating the Viewer:
@(Html.EJ().PdfViewer("pdfviewer").ServiceUrl("../../api/PdfViewer").PdfService(Syncfusion.JavaScript.PdfViewerEnums.PdfService.Local).DocumentPath(@Model.BaseString))
The Model is based on a class found on this site:
public class PdfBaseString
{
public string BaseString
{
get;
set;
}
}
In the PDF creation method I have the following (finalPDF is a byte[]):
PdfBaseString base64String = new PdfBaseString();
base64String.BaseString = "data:application/pdf;base64," + Convert.ToBase64String(finalPDF);
return View("ViewPdf", base64String);
The view displays, but with the PDFViewer showing a loading spinner.
In all the other examples I've found there's always a POST method being used to populate the model, but I will not have a postback on the page. Is that required? How does the PDFViewer load the data? What am I missing?
Thanks,
Bryan
SIGN IN To post a reply.
3 Replies
AA
Akshaya Arivoli
Syncfusion Team
February 14, 2018 11:37 AM UTC
Hi Bryan ,
Thank you for using Syncfusion products.
Please find the details of your query form the below table,
|
Query |
Details |
|
I've been trying to get the PDF Viewer to display a dynamically created PDF.
Here's what happens:
A user selects some data from a table, on the post back the PDF is generated and the user is returned to the PDFViewer View.
I've looked at many of the PDFViewer solutions on this site and have not found one that works for my situation. The main thing is, the PDF is not stored on the file system or in a database, it's to be created, displayed and destroyed.
My View has this creating the Viewer:
@(Html.EJ().PdfViewer("pdfviewer").ServiceUrl("../../api/PdfViewer").PdfService(Syncfusion.JavaScript.PdfViewerEnums.PdfService.Local).DocumentPath(@Model.BaseString))
The Model is based on a class found on this site:
public class PdfBaseString
{
public string BaseString
{
get;
set;
}
}
In the PDF creation method I have the following (finalPDF is a byte[]):
PdfBaseString base64String = new PdfBaseString();
base64String.BaseString = "data:application/pdf;base64," + Convert.ToBase64String(finalPDF);
return View("ViewPdf", base64String);
The view displays, but with the PDFViewer showing a loading spinner.
|
We regret to let you know that we are unable to reproduce the reported issue with the details provided in the incident. We have created the sample with the information and the code snippet provided in the incident and shared the same in following location,
Please try the above sample and revert us with the following details if still the issue is reproduced.
These details will be helpful for us to investigate more on your requirement and assist you better.
|
|
In all the other examples I've found there's always a POST method being used to populate the model, but I will not have a postback on the page. Is that required? How does the PDFViewer load the data? What am I missing? |
The PDF viewer is not fully client side control. The parsing of the PDF documents is performed on the server side of the control in the WebAPI control using the Ajax requests and then the document is rendered on the client side of the PDF Viewer control. Please find the UG documentation link below,
|
Regards,
Akshaya
BW
Bryan Warner
February 14, 2018 11:54 PM UTC
Thanks for your help and the demo project. I was able to figure out what I had wrong and get it working.
Thanks again,
Bryan
AA
Akshaya Arivoli
Syncfusion Team
February 15, 2018 05:13 AM UTC
Hi Brayn,
Thank you for your update and we are glad to know that your issue is resolved.
Regards,
Akshaya
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BW Bryan Warner
- Feb 13, 2018 06:42 PM UTC
- Feb 15, 2018 05:13 AM UTC