Hello,
I use, Syncfusion.EJ.PdfViewer version 17.3460.0.19 and .Net version 4.6.1.
I followed the documention to display a pdf on pdfviewer. In local the pdf is well displayed but on my server I obtain a error 500 for api/pdfviewer/Load, I don't understand why I have this error.
In my page I have :
<ej:PdfViewer Height="700" id="PdfViewer" runat="server" ServiceUrl="../api/PdfViewer" PdfService="Local" SignatureAdd="signatureAdded">
</ej:PdfViewer>
In my PdfViewerController :
public class PdfViewerController : ApiController
{
//Post action for processing the PDF documents.
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"))
{
if (jsonResult.ContainsKey("file"))
{
string name = HttpContext.Current.Server.MapPath("~/Data/" + jsonResult["file"].ToString().Substring(jsonResult["file"].ToString().IndexOf("/") + 1));
helper.Load(name);
}
else
{
helper.Load(HttpContext.Current.Server.MapPath("~/Data/EULA_OTPOne_EN.pdf"));
}
}
}
return JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
}
//Post action for processing the PDF documents when uploading to the ejPdfviewer widget.
public object FileUpload(Dictionary<string, string> jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
if (jsonResult.ContainsKey("uploadedFile"))
{
var fileUrl = jsonResult["uploadedFile"];
byte[] byteArray = Convert.FromBase64String(fileUrl);
MemoryStream stream = new MemoryStream(byteArray);
helper.Load(stream);
}
return JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult));
}
//Post action for downloading the PDF documents from the ejPdfviewer widget.
public object Download(Dictionary<string, string> jsonResult)
{
PdfViewerHelper helper = new PdfViewerHelper();
return helper.GetDocumentData(jsonResult);
}
//Post action for unloading and disposing the PDF document resources in server side from the ejPdfviewer widget.
public void Unload()
{
PdfViewerHelper helper = new PdfViewerHelper();
helper.UnLoad();
}
}
In my global :
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteTable.Routes.MapHttpRoute(name: "StripeWebhooks", routeTemplate: "api/{controller}/");
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("mylicencekey");
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional });
}