A server side exception:
System.OverflowException: 'Value was either too large or too small for a Double.'
is thrown on attempting to serialize an existing .pdf file converted to FixedDocument.
public ActionResult GetInitialPdf(int? pageNumber)
{
//exception with Development plan.pdf file:
string filePath = Path.Combine(Server.MapPath("~/Content/web/pdfViewer"), "Development Plan.pdf");
//it works with the sample.pdf file:
//string filePath = Path.Combine(Server.MapPath("~/App_Data"), "sample.pdf");
FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
JsonResult jsonResult;
FixedDocument doc = FixedDocument.Load(stream);
if (pageNumber == null)
{
jsonResult = Json(doc.ToJson(), JsonRequestBehavior.AllowGet);
}
else
{
jsonResult = Json(doc.GetPage((int)pageNumber), JsonRequestBehavior.AllowGet);
}
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
}
The exception is thrown during the FixedDocument JSON serialization:
doc.ToJson()
at the following place: ConvertToList method in ArrayExtension class (Telerik.Web.PDF namespace)
No exceptions are thrown during serialization.