Example #1
0
        public ActionResult Load(jsonObjects jsonObject)
        {
            PdfRenderer  pdfviewer  = new PdfRenderer();
            MemoryStream stream     = new MemoryStream();
            var          jsonData   = JsonConverter(jsonObject);
            object       jsonResult = new object();

            if (jsonObject != null && jsonData.ContainsKey("document"))
            {
                if (bool.Parse(jsonData["isFileName"]))
                {
                    string documentPath = GetDocumentPath(jsonData["document"]);
                    if (!string.IsNullOrEmpty(documentPath))
                    {
                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath);
                        stream = new MemoryStream(bytes);
                    }
                    else
                    {
                        return(this.Content(jsonData["document"] + " is not found"));
                    }
                }
                else
                {
                    byte[] bytes = Convert.FromBase64String(jsonData["document"]);
                    stream = new MemoryStream(bytes);
                }
            }
            jsonResult = pdfviewer.Load(stream, jsonData);
            return(Content(JsonConvert.SerializeObject(jsonResult)));
        }
Example #2
0
        public ActionResult Unload(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);

            pdfviewer.ClearCache(jsonData);
            return(this.Content("Document cache is cleared"));
        }
Example #3
0
        public ActionResult RenderAnnotationComments(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer  = new PdfRenderer();
            var         jsonData   = JsonConverter(jsonObject);
            object      jsonResult = pdfviewer.GetAnnotationComments(jsonData);

            return(Content(JsonConvert.SerializeObject(jsonResult)));
        }
Example #4
0
        public ActionResult ExportFormFields(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer  = new PdfRenderer();
            var         jsonData   = JsonConverter(jsonObject);
            string      jsonResult = pdfviewer.ExportFormFields(jsonData);

            return(Content(jsonResult));
        }
Example #5
0
        public ActionResult ExportAnnotations(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);
            string      result    = pdfviewer.ExportAnnotation(jsonData);

            return(Content(result));
        }
Example #6
0
        public ActionResult RenderPdfTexts(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);
            object      result    = pdfviewer.GetDocumentText(jsonData);

            return(Content(JsonConvert.SerializeObject(result)));
        }
Example #7
0
        public ActionResult PrintImages(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);
            object      pageImage = pdfviewer.GetPrintImage(jsonData);

            return(Content(JsonConvert.SerializeObject(pageImage)));
        }
Example #8
0
        public ActionResult Download(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer    = new PdfRenderer();
            var         jsonData     = JsonConverter(jsonObject);
            string      documentBase = pdfviewer.GetDocumentAsBase64(jsonData);

            return(Content(documentBase));
        }
Example #9
0
        public ActionResult RenderThumbnailImages(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);
            object      result    = pdfviewer.GetThumbnailImages(jsonData);

            return(Content(JsonConvert.SerializeObject(result)));
        }
Example #10
0
        public ActionResult ImportFormFields(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer = new PdfRenderer();
            var         jsonData  = JsonConverter(jsonObject);

            jsonData["data"] = GetDocumentPath(jsonData["data"]);
            object jsonResult = pdfviewer.ImportFormFields(jsonData);

            return(Content(JsonConvert.SerializeObject(jsonResult)));
        }
Example #11
0
        public Dictionary <string, string> JsonConverter(jsonObjects results)
        {
            Dictionary <string, object> resultObjects = new Dictionary <string, object>();

            resultObjects = results.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
                            .ToDictionary(prop => prop.Name, prop => prop.GetValue(results, null));
            var emptyObjects = (from kv in resultObjects
                                where kv.Value != null
                                select kv).ToDictionary(kv => kv.Key, kv => kv.Value);
            Dictionary <string, string> jsonResult = emptyObjects.ToDictionary(k => k.Key, k => k.Value.ToString());

            return(jsonResult);
        }
Example #12
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));
        }
Example #13
0
        public ActionResult ImportAnnotations(jsonObjects jsonObject)
        {
            PdfRenderer pdfviewer  = new PdfRenderer();
            string      jsonResult = string.Empty;
            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"));
                }
            }
            return(Content(jsonResult));
        }