Problem viewing multi page PDF

Hello,

When loading a PDF document into the PDF Viewer, the first page will display but the second page (and others do not).  

In my controller, the Load method is being called for the first page, then the second.  On the second page call, the dictionary object passed to the method does not have a 'newFileName' dictionary entry that would specify the path to the document.  So, the second page load fails.

The PDF Viewer is hosted in a Dialog control.  From the client, I am passing a URL with the PDF Viewer Load method.

Can you help me see what I am doing incorrectly here?

Thank you,
Randy Craven

Here is the client side code:

function showPdfViewer(modalId, pdfViewerId, mediaUrl, caption) {
    const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
    const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);

    $('#' + modalId).ejDialog({
        enableResize: false,
        showHeader: true,
        showOnInit: false,
        showRoundedCorner: true,
        height: vh,
        enableModal: true,
        open: function () {
            $('#' + pdfViewerId).ejPdfViewer({
                allowClientBuffering: true,
                bufferingMode: ej.PdfViewer.BufferingMode.Complete,
                pdfService: ej.PdfViewer.PdfService.Local,
                serviceUrl: '../../api/PdfViewer'
            });
            var pdfviewerObj = $('#' + pdfViewerId).data('ejPdfViewer');
            pdfviewerObj.load(mediaUrl);
        },
        position: { X: 0, Y: 0 },
        isResponsive: false,
        title: caption,
        width: vw
    });
    $('#' + modalId).ejDialog('open');
}
 And here is the controller code:

        public object Load(Dictionary<string, string> jsonResult)
        {
            PdfViewerHelper helper = new PdfViewerHelper();
            string mediaUrl;
            jsonResult.TryGetValue("newFileName", out mediaUrl);
            var WebClient = new WebClient();
            byte[] pdfDoc = WebClient.DownloadData(mediaUrl);
            helper.Load(pdfDoc);
            object output = helper.ProcessPdf(jsonResult);
            return JsonConvert.SerializeObject(output);
        }

3 Replies 1 reply marked as answer

MS Mohan Selvaraj Syncfusion Team August 24, 2020 12:10 PM UTC

Hi Randy , 

Thank you for using Syncfusion products. 

We will pass the newFileName parameter only on initial loading of the 1st page , then for the remaining pages we will just retrieve the data by using  the helper.ProcessPdf(jsonResult); method. So we need to modify the controller code like below. 

    public object Load(Dictionary<string, string> jsonResult) 
        { 
            PdfViewerHelper helper = new PdfViewerHelper(); 
            string mediaUrl; 
  if (jsonResult.ContainsKey("newFileName")){           
  jsonResult.TryGetValue("newFileName", out mediaUrl); 
            var WebClient = new WebClient(); 
            byte[] pdfDoc = WebClient.DownloadData(mediaUrl); 
            helper.Load(pdfDoc); 
} 
            object output = helper.ProcessPdf(jsonResult); 
            return JsonConvert.SerializeObject(output); 
        } 


In this we will use the Load method for initial rendering of the PDF pages for remaining pages we don’t need the Load method we just return the needed details from the helper.ProcessPdf(jsonResult); method. 


Regards, 
Mohan S

Marked as answer

RC Randy Craven August 24, 2020 05:17 PM UTC

Hello Mohan S,

Thank you very much.  Your suggestion worked.

Randy Craven


AA Akshaya Arivoli Syncfusion Team August 25, 2020 07:35 AM UTC

Hi Randy, 

Thank you for your update. We are glad to know that the reported issue is resolved. Please revert us if you need further assistance.  

Regards, 
Akshaya 


Loader.
Up arrow icon