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);
}