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. Image for the cookie policy date

How to use with filename

Hello.

Pardon me, but I simply don´t understand how to use the PDF-Viewer for displaying a file.

I have the following scenario:

I have a grid which displays invoices. When i select an invoice, I enable a button on the toolbar for opening the invoice using a modal window which should contain a pdf viewer.
So far so good.

What I don´t understand is, when I follow the samples provided by you, how to tell the pdf-viewer which file to load.
The moment I create the viewer (using typescript) it tries to access the web-api controller - which is expected to return the pdf file. But I don´t know which file to load at this time.
Do you expect me to provide a dummy-file initially and then to load the correct file? If how do I do this - the load function in typescript doesn´t expect a parameter.

Thanks for your help!

Florian


5 Replies

SA Sabari Anand Senthamarai Kannan Syncfusion Team December 9, 2016 09:31 AM UTC

Hi Florian, 
 
Thank you for using Syncfusion products. 
 
Please find the details for your query in the below table 
 
Query 
Details 
The moment I create the viewer (using typescript) it tries to access the web-api controller - which is expected to return the pdf file. But I don´t know which file to load at this time. 
Do you expect me to provide a dummy-file initially and then to load the correct file? 
You can create a webAPI controller as custom in your project and use the same. There is no need to provide a dummy file in the controller. Once you load the PDF document in the PDF viewer using the load function, the document will be loaded fine. 
If how do I do this - the load function in typescript doesn´t expect a parameter. 
We have created a new incident under your account for this query. We request you to follow the new incident for further updates. You can log in to our support system using the following link,  
  
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Sabari Anand 



FM Florian Mihalits December 10, 2016 03:45 PM UTC

Hello Sabari.

Thank you. I´m still not sure how to design the API-Controller properly.
Would you be so kind to provide a "neutral" implementation?

Thank you very much!

All the best,
Florian


SA Sabari Anand Senthamarai Kannan Syncfusion Team December 12, 2016 10:54 AM UTC

Hi Florian, 
 
Thank you for your update. 
 
You can create a Web API controller for the PDF viewer control using our UG documentation. Please follow the below documentation link for more details, 
 
 
We have also created a simple sample with the web API controller for the PDF viewer control of Essential Studio version 14.4.0.15. You can download the sample from the following link, 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Sabari Anand


FM Florian Mihalits December 12, 2016 12:04 PM UTC

Hello.

Sorry, but ALL of your samples include some sort of "filename" for the first request or at least expect one.
Look at the following sample implementation provided by syncfusion (you):

public object Load(Dictionary<string, string> jsonResult)
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            //load the multiple document from client side
            if (jsonResult.ContainsKey("newFileName"))
            {
                var name = jsonResult["newFileName"];
                var pdfName = name.ToString() + ".pdf";
                helper.Load(HttpContext.Current.Server.MapPath("~/Data/" + pdfName));
            }
            else
            {
                if (jsonResult.ContainsKey("isInitialLoading"))
                    helper.Load(HttpContext.Current.Server.MapPath("~/Data/HTTP Succinctly.pdf"));
            }
            string output = JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
            return output;
        }


Take a look at helper.Load(HttpContext.Current.Server.MapPath("~/Data/HTTP Succinctly.pdf"));.
You are loading a PDF-Document if no "newfileName" is provided.

When I create an instance of the pdfviewer like this:  "$("#container").ejPdfViewer({ serviceUrl: '../api/PdfViewer', pdfService: ej.PdfViewer.PdfService.Local });" the pdf-viewer component calls the web-api immediately. And "helper.ProcessPdf" expects a file to be provided.

So, how can I initialize the pdf-viewer control without providing a filename?

I hope I now could explain my problem.

Thank you!

All the best, Florian





BS Balasubramanian Sundararajan Syncfusion Team December 13, 2016 10:10 AM UTC

Hi Florian, 
 
Thank you for your update. 
 
At present we do not support initializing PDF viewer control without file name. However, we have plans to implement the feature for initializing PDF viewer without the file name. This feature may be expected in any of our upcoming releases. 
 
Thanks, 
Balasubramanian S 


Loader.
Live Chat Icon For mobile
Up arrow icon