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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PDfViewer Example - not able to send request for specific PDF File

Thread ID:

Created:

Updated:

Platform:

Replies:

127871 Dec 14,2016 04:55 PM UTC Dec 19,2016 06:06 AM UTC ASP.NET MVC 5
loading
Tags: PdfViewer
Cal
Asked On December 14, 2016 04:55 PM UTC

Hi

I've been trying to implement PDFViewer.

We have built your sample project and we have used some of the code from it. We are now trying to move over from just serving one test pdf and sending over a parameter to send back a unique pdf.

Here is the code you provide

Public Class PdfViewerController
    Inherits ApiController

    Public Function PostViewerAction(jsonResult As Dictionary(Of String, String)) As Object
        Dim helper__1 As New PdfViewerHelper()
        'load the multiple document from client side 

        If jsonResult.ContainsKey("newFileName") Then
            Dim name = jsonResult("newFileName")
            Dim pdfName = name.ToString() & ".pdf"
            helper__1.Load(Helper.GetFilePath("" & pdfName))
        Else
            If jsonResult.ContainsKey("isInitialLoading") Then
                helper__1.Load(Helper.GetFilePath("receipttest.pdf"))
            End If
        End If



        'If ReceiptNo <> Nothing Then
        'Dim filePathThing As String = info.ReceiptNo & ".pdf"
        'helper__1.Load(Helper.GetFilePath(filePathThing))
        'End If

        Dim output As String = JsonConvert.SerializeObject(helper__1.ProcessPdf(jsonResult))
        Return output
    End Function
    Public Function DocumentDownloadAction(jsonResult As Dictionary(Of String, String)) As Object
        Dim helper As New PdfViewerHelper()
        Return New With {Key .DocumentStream = Convert.ToBase64String(helper.DocumentStream.ToArray())}
    End Function
End Class

Public Class Helper
    Public Shared Function GetFilePath(path As String) As String
        Dim _dataPath As String = GetCommonFolder(New DirectoryInfo(HttpContext.Current.Request.PhysicalApplicationPath))
        _dataPath += "\" & path
        Return _dataPath
    End Function

    Private Shared Function GetCommonFolder(dtInfo As DirectoryInfo) As String
        Dim _folderNames = dtInfo.GetDirectories("Data/PdfViewer")
        If _folderNames.Length > 0 Then
            Return _folderNames(0).FullName
        End If

        Return If(dtInfo.Parent IsNot Nothing, GetCommonFolder(dtInfo.Parent), String.Empty)
    End Function
End Class

How can we do this?

Thanks

Aravinth Sampath [Syncfusion]
Replied On December 15, 2016 07:16 AM UTC

Hi Callam, 
 
Thank you for contacting Syncfusion support. 
 
At present, we do not have support for passing parameters to WebAPI method in PDF viewer control. Can you please provide us the details like what kind of parameters you are going to pass to the WebAPI controller of PDF viewer control and their usage in your project. So, that it will be helpful for us to analyze further on your requirement and assist you better. 
 
Regards, 
Aravinth

Cal
Replied On December 15, 2016 09:13 AM UTC

Hi Callam, 
 
Thank you for contacting Syncfusion support. 
 
At present, we do not have support for passing parameters to WebAPI method in PDF viewer control. Can you please provide us the details like what kind of parameters you are going to pass to the WebAPI controller of PDF viewer control and their usage in your project. So, that it will be helpful for us to analyze further on your requirement and assist you better. 
 
Regards, 
Aravinth

Hi

We are trying to pass 2 parameters, filename (String) and some sort of ID as Integer.

Thank you

Akshaya Arivoli [Syncfusion]
Replied On December 16, 2016 07:09 AM UTC

Hi Callam,  
 
Thank you for your update. 
 
As mentioned earlier at present we do not have support for passing parameters to WebAPI method. However, as per your requirement we have created the work around sample to pass the Name of the PDF document to the server for loading the document in the PDF Viewer control using AJAX request. You can download the sample from the following link. 
 
 
Please try the provided sample and if it was differ from your requirement, please provide more details about the usage of parameters. So, that it will be helpful for us to analyze further on your requirement and assist you better. 
 
Regards, 
Akshaya 


Cal
Replied On December 16, 2016 03:01 PM UTC

Hi,

Thanks for your help. This looks like a good solution, however we are having some trouble with the JavaScript as it's claiming for us that ejPdfViewer is not a function.

This is in this part of the code: 
                    function openDoc(data) {
                        if (!isControlInitialized) {
                            $("#pdfviewer").ejPdfViewer({ serviceUrl: "../../api/PdfViewer", pdfService: ej.PdfViewer.PdfService.Local });
                            isControlInitialized = true;
                        }
                        var obj = $("#pdfviewer").data("ejPdfViewer");
                        obj.load(data);
                    }

Thank you for your help so far


Akshaya Arivoli [Syncfusion]
Replied On December 19, 2016 06:06 AM UTC

Hi Callam, 
 
Thank you for your update. 
 
We are unable to reproduce the reported error in the provided sample. We suspect the reported error may due to the improper referring of DLL’s and script files. So, can you please ensure whether the assemblies and script files are referring properly in the sample.  
 
Also, we have shared the demo video showing that the PDF viewer control is rendered properly in the provided sample. Please find it from the following location. 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Akshaya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;