Exemplo n.º 1
0
        public void Addsignature(int id)
        {
            FilesRepo filesRepo = new FilesRepo(context);


            //IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
            //// add a footer too
            //Renderer.PrintOptions.Footer.DrawDividerLine = true;
            //Renderer.PrintOptions.Footer.FontFamily = "Arial";
            //Renderer.PrintOptions.Footer.FontSize = 10;
            //Renderer.PrintOptions.Footer.LeftText = "SIGNED BY";
            //Renderer.PrintOptions.Footer.RightText = "WANGOCHO";

            //// add footer to the pdf

            string             filepath = filesRepo.GetfilePath(id);
            PdfDocument        Pdf      = PdfDocument.FromFile(filepath);
            SimpleHeaderFooter footer   = new SimpleHeaderFooter();

            footer.LeftText        = "signed by";
            footer.RightText       = "nanii";
            footer.Spacing         = 5;
            footer.DrawDividerLine = true;

            Pdf.AddFooters(footer, false, null);
            Pdf.SaveAs(filepath);
        }
Exemplo n.º 2
0
        public async Task <JObject> DeleteFile(int id)
        {
            FilesRepo filesRepo = new FilesRepo(context);
            ///create jsonObject
            JObject jObject = new JObject();
            /// get the file path
            string filepath = filesRepo.GetfilePath(id);

            if (String.IsNullOrWhiteSpace(filepath))
            {
                jObject.Add("status", 500);
                jObject.Add("message", "file path wasnt found");
            }
            /// delete from local file
            if (System.IO.File.Exists(filepath))
            {
                // Use a try block to catch IOExceptions, to
                // handle the case of the file already being
                // opened by another process.
                try
                {
                    System.IO.File.Delete(filepath);
                }
                catch (System.IO.IOException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            await filesRepo.DeleteFile(id);

            jObject.Add("status", 200);
            jObject.Add("message", "success");

            return(jObject);
        }
Exemplo n.º 3
0
        public JObject GetPdfByte(int FileId)
        {
            FilesRepo filesRepo = new FilesRepo(context);

            byte[]  bytes   = System.IO.File.ReadAllBytes(filesRepo.GetfilePath(FileId));
            JObject jObject = new JObject();

            jObject.Add("byte", bytes);

            return(jObject);
        }