コード例 #1
0
        public ActionResult ImportAnnotations(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer  = new PdfRenderer();
            string      jsonResult = string.Empty;
            object      JsonResult;
            var         jsonData = JsonConverter(jsonObject);

            if (jsonObject != null && jsonData.ContainsKey("fileName"))
            {
                string documentPath = GetDocumentPath(jsonData["fileName"]);
                if (!string.IsNullOrEmpty(documentPath))
                {
                    jsonResult = System.IO.File.ReadAllText(documentPath);
                }
                else
                {
                    return(Content(jsonData["document"] + " is not found"));
                }
            }
            else
            {
                string extension = Path.GetExtension(jsonData["importedData"]);
                if (extension != ".xfdf")
                {
                    JsonResult = pdfviewer.ImportAnnotation(jsonData);
                    return(Content(JsonConvert.SerializeObject(JsonResult)));
                }
                else
                {
                    string documentPath = GetDocumentPath(jsonData["importedData"]);
                    if (!string.IsNullOrEmpty(documentPath))
                    {
                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
                        jsonData["importedData"] = Convert.ToBase64String(bytes);
                        JsonResult = pdfviewer.ImportAnnotation(jsonData);
                        return(Content(JsonConvert.SerializeObject(JsonResult)));
                    }
                    else
                    {
                        return(Content(jsonData["document"] + " is not found"));
                    }
                }
            }
            return(Content(jsonResult));
        }