Example #1
0
        //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)));
        }
Example #2
0
        public JsonResult Download(jsonObjects result)
        {
            PdfViewerHelper helper     = new PdfViewerHelper();
            var             jsonResult = JsonConverterstring(result);

            if (jsonResult.ContainsKey("savedFields"))
            {
                var values = jsonResult["savedFields"];
                Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(values);
                jsonResult = data;
            }
            return(Json(helper.GetDocumentData(jsonResult)));
        }
Example #3
0
        public ActionResult FileUpload(jsonObjects result)
        {
            PdfViewerHelper helper     = new PdfViewerHelper();
            var             jsonResult = JsonConverterstring(result);

            if (jsonResult.ContainsKey("uploadedFile"))
            {
                var          fileurl   = jsonResult["uploadedFile"];
                byte[]       byteArray = Convert.FromBase64String(fileurl);
                MemoryStream stream    = new MemoryStream(byteArray);
                helper.Load(stream);
            }
            return(Content(JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult))));
        }
Example #4
0
        public ActionResult Load(jsonObjects results)
        {
            PdfViewerHelper helper     = new PdfViewerHelper();
            var             jsonResult = JsonConverterstring(results);

            //load the multiple document from client side
            if (jsonResult.ContainsKey("newFileName"))
            {
                var name    = jsonResult["newFileName"];
                var pdfName = name.ToString() + ".pdf";
                helper.Load(Helper.GetFilePath("" + pdfName));
            }
            else
            {
                //Initially load the PDF document from the data folder.
                if (jsonResult.ContainsKey("isInitialLoading"))
                {
                    helper.Load(Helper.GetFilePath("FormFillingDocument.pdf"));
                }
            }
            return(Content(JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult))));
        }
Example #5
0
        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"];
                string fileName = name.Split(new string[] { "://" }, StringSplitOptions.None)[0];
                if (fileName == "http" || fileName == "https")
                {
                    var    WebClient = new WebClient();
                    byte[] pdfDoc    = WebClient.DownloadData(name);
                    helper.Load(pdfDoc);
                }
                else
                {
                    string path = HttpContext.Current.Server.MapPath("~/FileBrowser/Document/" + name);

                    IPresentation pptxDoc = Presentation.Open(path);

                    //Creates an instance of ChartToImageConverter and assigns it to ChartToImageConverter property of Presentation
                    pptxDoc.ChartToImageConverter = new ChartToImageConverter();

                    //Converts the PowerPoint Presentation into PDF document
                    PdfDocument  pdfDocument = PresentationToPdfConverter.Convert(pptxDoc);
                    MemoryStream ms          = new MemoryStream();
                    pdfDocument.Save(ms);
                    //     System.IO.File.WriteAllBytes(HttpContext.Current.Server.MapPath("~/FileBrowser/Document/out.pdf"), ms.ToArray());
                    //Closes the PDF document
                    pdfDocument.Close(true);

                    //Closes the Presentation
                    pptxDoc.Close();
                    helper.Load(ms);
                }
            }
            else
            {
                if (jsonResult.ContainsKey("isInitialLoading"))
                {
                    if (jsonResult.ContainsKey("file"))
                    {
                        var    name     = jsonResult["file"];
                        string fileName = name.Split(new string[] { "://" }, StringSplitOptions.None)[0];
                        if (fileName == "http" || fileName == "https")
                        {
                            var    WebClient = new WebClient();
                            byte[] pdfDoc    = WebClient.DownloadData(name);
                            helper.Load(pdfDoc);
                        }
                        else
                        {
                            helper.Load(name);
                        }
                    }
                    else
                    {
                        byte[] doc = System.IO.File.ReadAllBytes(HttpContext.Current.Server.MapPath("~/Data/HTTP Succinctly.pdf"));
                        //helper.Load(HttpContext.Current.Server.MapPath("~/Data/HTTP Succinctly.pdf"));
                        helper.Load(doc);
                    }
                }
            }
            return(JsonConvert.SerializeObject(helper.ProcessPdf(jsonResult)));
        }
Example #6
0
        //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();
        }
Example #7
0
        //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));
        }
 protected override void OnAttached()
 {
     base.OnAttached();
     PdfViewerHelper.AddFunctionalLimitsOccuredHandler(AssociatedObject, FunctionalLimitsOccuresHandler);
 }