protected void BtnPrintPDF_Click(object sender, ImageClickEventArgs e)
    {
        EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(11.69f, 8.27f);
        PdfDocument doc = new PdfDocument();


        string GUID = Guid.NewGuid().ToString();

        string filePath = Server.MapPath("~/Uploads/Reports/" + GUID + ".pdf");

        EO.Pdf.Runtime.AddLicense("p+R2mbbA3bNoqbTC4KFZ7ekDHuio5cGz4aFZpsKetZ9Zl6TNHuig5eUFIPGe" +
                                  "tcznH+du5PflEuCG49jjIfewwO/o9dB2tMDAHuig5eUFIPGetZGb566l4Of2" +
                                  "GfKetZGbdePt9BDtrNzCnrWfWZekzRfonNzyBBDInbW6yuCwb6y9xtyxdabw" +
                                  "+g7kp+rp2g+9RoGkscufdePt9BDtrNzpz+eupeDn9hnyntzCnrWfWZekzQzr" +
                                  "peb7z7iJWZekscufWZfA8g/jWev9ARC8W7zTv/vjn5mkBxDxrODz/+ihb6W0" +
                                  "s8uud4SOscufWbOz8hfrqO7CnrWfWZekzRrxndz22hnlqJfo8h8=");
        EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div style='text-align:center; font-family:Tahoma; font-size:10px;'>Page {page_number} of {total_pages}</div>";
        HtmlToPdf.ConvertHtml(hdnContent.Value, filePath);


        newtab = UDFLib.ConvertToInteger(ViewState["newtabnumber"]);
        newtab++;
        ViewState["newtabnumber"] = newtab;

        ScriptManager.RegisterStartupScript(this, this.GetType(), "hideText", "window.open('../../Uploads/Reports/" + GUID + ".pdf','ATT" + newtab + "');", true);  // (  this.GetType(), "OpenWindow", "window.open('../../Uploads/InspectionReport.pdf','_newtab');", true);
    }
Пример #2
0
        public static byte[] GetPDF(Int16 mode, string HTMLtext = null, string url = null)
        {
            EO.Pdf.Runtime.AddLicense(
                "ua9qsKaxHvSbvPwBFPGe6sUF6KFtprXJ2rFpqbSzy/We6ff6Gu12mbXKzZ9o" +
                "tZGby59Zl8AEFOan2PgGHeR3ufP5DNKr58ngFbChudfn2tGxqubB7Lx2s7ME" +
                "FOan2PgGHeR3hI7N2uui2un/HuR3hI514+30EO2s3MKetZ9Zl6TNF+ic3PIE" +
                "EMidtbbB3Lhpq7bD269qrbbH3bJmqMDAF+ic3PIEEMidtZGby59Zl8D9FOKe" +
                "5ff2EL11pvD6DuSn6un26YxDl6Sxy7ua4/AAIr1GgaSxy59Zl6Sx5+Cd26QF" +
                "JO+etKbW+q2J2+qzy/We6ff6Gu12mbXK2a9bl7PPuIlZl6Sx566a4/AAIr1G" +
                "gaSxy5915vb1EPGC5eoAy+Oa6+nOzbNoqLzA3Q==");
            PdfDocument doc = new PdfDocument();

            if (mode == 1) // convert from HTML string
            {
                string style = @"<style>.fr-view table {
    border: 0;
    border-collapse: collapse;
    empty-cells: show;
    max-width: 100%;
} .fr-view table td, .fr-view table th {
          border: 1px solid #ddd;
      }</style>";
                HtmlToPdf.ConvertHtml(style + HTMLtext, doc);
            }
            MemoryStream stream = new MemoryStream();

            doc.Save(stream);
            byte[] data = stream.ToArray();
            return(data);
        }
Пример #3
0
        public static byte[] ToPDF(string Html)
        {
            var filename = System.Web.HttpContext.Current.Server.MapPath("~/Temp/" + Helpers.Time.ToTimeStamp(DateTime.Now) + ".pdf");

            HtmlToPdf.ConvertHtml(Html, filename);
            var pdfBytes = System.IO.File.ReadAllBytes(filename);

            System.IO.File.Delete(filename);
            return(pdfBytes);
        }
Пример #4
0
 public RenderResult PDFFromHtml(string html)
 {
     try
     {
         using (var stream = new MemoryStream())
         {
             HtmlToPdf.ConvertHtml(html, stream);
             return(new RenderResult {
                 Success = true, Data = stream.GetBuffer()
             });
         }
     }
     catch (Exception ex)
     {
         return(new RenderResult {
             Success = false, ExceptionMessage = ex.Message
         });
     }
 }
Пример #5
0
        /// <summary>
        /// Converts an HTML page to PDF using the given options
        /// </summary>
        /// <param name="html">The HTML content to convert.</param>
        /// <param name="output">The output stream.</param>
        /// <param name="options">The options to use for the conversion.</param>
        public static void Convert(string html, Stream output, HtmlToPdfConverterOptions options)
        {
            // Sets the license
            SetLicense();

            // Initialize parameters
            var opts = InitParameters(html, options);

#if DEBUG
            using (var fw = File.CreateText(@"C:\temp\js_out.txt"))
            {
                HtmlToPdf.DebugConsole = fw;
                HtmlToPdf.ConvertHtml(html, output, opts);
            }
#else
            // Convert HTMl to PDF
            HtmlToPdf.ConvertHtml(html, output, opts);
#endif
        }
Пример #6
0
    /// <summary>
    /// To Format and generate Pdf and save in specified location.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnrp_Click(object sender, EventArgs e)
    {
        try
        {
            string TemplateText = hdnReport.Value;


            EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(11.0f, 11.69f);
            string GUID = Guid.NewGuid().ToString();


            string filePath = Server.MapPath("~/Uploads/Purchase/" + GUID + ".pdf");

            string savefilepath = "Uploads/Purchase/" + GUID + ".pdf";

            EO.Pdf.Runtime.AddLicense("p+R2mbbA3bNoqbTC4KFZ7ekDHuio5cGz4aFZpsKetZ9Zl6TNHuig5eUFIPGe" +
                                      "tcznH+du5PflEuCG49jjIfewwO/o9dB2tMDAHuig5eUFIPGetZGb566l4Of2" +
                                      "GfKetZGbdePt9BDtrNzCnrWfWZekzRfonNzyBBDInbW6yuCwb6y9xtyxdabw" +
                                      "+g7kp+rp2g+9RoGkscufdePt9BDtrNzpz+eupeDn9hnyntzCnrWfWZekzQzr" +
                                      "peb7z7iJWZekscufWZfA8g/jWev9ARC8W7zTv/vjn5mkBxDxrODz/+ihb6W0" +
                                      "s8uud4SOscufWbOz8hfrqO7CnrWfWZekzRrxndz22hnlqJfo8h8=");

            HtmlToPdf.ConvertHtml(TemplateText, filePath);
            PdfDocument doc = new PdfDocument(filePath);

            AcmRender render = new AcmRender(doc);
            render.BeforeRenderPage += new AcmPageEventHandler(render_BeforeRenderPage);
            EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div style='text-align:center; font-family:Tahoma; font-size:12px'>Page {page_number} of {total_pages}</div>";
            EO.Pdf.HtmlToPdf.Options.AutoFitX         = HtmlToPdfAutoFitMode.None;
            AcmContent acmCon = new AcmContent();
            render.Render(acmCon);

            doc.Save(filePath);
            BLL_PURC_Common.PURC_UPD_CancelPO_FilePath(Convert.ToString(Request.QueryString["ORDER_CODE"]), "", savefilepath, "", Convert.ToInt32(Session["userid"].ToString()));
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }
Пример #7
0
    protected void BtnPrintPDF_Click(object sender, EventArgs e)
    {
        EO.Pdf.HtmlToPdf.Options.PageSize = new SizeF(33.1f, 23.4f);

        PdfDocument doc = new PdfDocument();

        string GUID     = Guid.NewGuid().ToString();
        string filePath = Server.MapPath("~/Uploads/Reports/" + GUID + ".pdf");

        //string FileName = "~/Uploads/Reports/" + GUID + ".pdf";

        EO.Pdf.Runtime.AddLicense("p+R2mbbA3bNoqbTC4KFZ7ekDHuio5cGz4aFZpsKetZ9Zl6TNHuig5eUFIPGe" +
                                  "tcznH+du5PflEuCG49jjIfewwO/o9dB2tMDAHuig5eUFIPGetZGb566l4Of2" +
                                  "GfKetZGbdePt9BDtrNzCnrWfWZekzRfonNzyBBDInbW6yuCwb6y9xtyxdabw" +
                                  "+g7kp+rp2g+9RoGkscufdePt9BDtrNzpz+eupeDn9hnyntzCnrWfWZekzQzr" +
                                  "peb7z7iJWZekscufWZfA8g/jWev9ARC8W7zTv/vjn5mkBxDxrODz/+ihb6W0" +
                                  "s8uud4SOscufWbOz8hfrqO7CnrWfWZekzRrxndz22hnlqJfo8h8=");
        // HtmlToPdf.Options.AfterRenderPage = new EO.Pdf.PdfPageEventHandler(On_AfterRenderPage);
        EO.Pdf.HtmlToPdf.Options.FooterHtmlFormat = "<div style='text-align:right; font-family:calibri; font-size:12px'>Page {page_number} of {total_pages}</div>";

        HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None;
        //HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.None;


        // HtmlToPdf.Options.AutoAdjustForDPI=true;
        //  HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.Letter;
        string TemplateText = hdnContent.Value;

        HtmlToPdf.ConvertHtml(TemplateText, filePath);

        newtab = UDFLib.ConvertToInteger(ViewState["newtabnumber"]);
        newtab++;
        ViewState["newtabnumber"] = newtab;
        ScriptManager.RegisterStartupScript(this, this.GetType(), "hideText", "window.open('../../Uploads/Reports/" + GUID + ".pdf','INSPRPT" + newtab + "');", true);  // (  this.GetType(), "OpenWindow", "window.open('../../Uploads/InspectionReport.pdf','_newtab');", true);
        //Response.Redirect("../../Uploads/Reports/" + GUID + ".pdf");
    }
Пример #8
0
        public InvoiceModule()
        {
            this.RequiresAuthentication();
            Post["/createinvoice"] = p =>
            {
                try
                {
                    Invoices result = this.InvoiceService().Create(this.Request.Form.invoice, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(result));
                }
                catch (Exception ex)
                {
                    return(Response.AsJson(new { error = true, message = ex.Message }));
                }
            };
            Get["/GetDataInvoice"] = p =>
            {
                int countInvoice = this.InvoicesQueryRepository().CountInvoice(this.CurrentAccount().OwnerId);
                return(Response.AsJson(countInvoice));
            };
            Get["/GetDataInvoiceToPaging/{start}/{limit}"] = p =>
            {
                int start = p.start;
                int limit = p.limit;
                IEnumerable <Invoices> invoices = this.InvoicesQueryRepository().GetDataInvoiceToPaging(this.CurrentAccount().OwnerId, start, limit);
                return(Response.AsJson(invoices));
            };
            Get["/GetDataInvoiceToPDF/{id}"] = p =>
            {
                Guid          invoiceId     = p.id;
                Invoices      invoice       = this.InvoicesQueryRepository().FindById(invoiceId, this.CurrentAccount().OwnerId);
                InvoiceReport invoiceReport = new InvoiceReport(invoice);
                Customer      customer      = this.CustomerReportRepository().GetCustomerById(Guid.Parse(invoice.CustomerId));
                Organization  organization  = this.OrganizationReportRepository().FindByOwnerId(this.CurrentAccount().OwnerId);

                LogoOrganization logo     = this.LogoOrganizationQuery().GetLogo(this.CurrentAccount().OwnerId);
                DefaultTemplate  template = new DefaultTemplate();

                string html = template.GetInvoiceDefaultTemplate(invoiceReport, customer, organization, logo);
                EO.Pdf.Runtime.AddLicense("aP0BELxbvNO/++OfmaQHEPGs4PP/6KFspbSzy653hI6xy59Zs7PyF+uo7sKe" +
                                          "tZ9Zl6TNGvGd3PbaGeWol+jyH+R2mbbA3a5rp7XDzZ+v3PYEFO6ntKbEzZ9o" +
                                          "tZGby59Zl8AEFOan2PgGHeR3q9bF266OzffU8MOSwdXjFvlww7vSIrx2s7ME" +
                                          "FOan2PgGHeR3hI7N2uui2un/HuR3hI514+30EO2s3MKetZ9Zl6TNF+ic3PIE" +
                                          "EMidtbjC4K9qq73K47J1pvD6DuSn6unaD71GgaSxy5914+30EO2s3OnP566l" +
                                          "4Of2GfKe3MKetZ9Zl6TNDOul5vvPuIlZl6Sxy59Zl8DyD+NZ6w==");
                EO.Pdf.HtmlToPdf.Options.OutputArea = new System.Drawing.RectangleF(0.5f, 0.3f, 7.5f, 10f);
                MemoryStream memStream = new MemoryStream();
                HtmlToPdf.ConvertHtml(html, memStream);
                MemoryStream resultStream = new MemoryStream(memStream.GetBuffer());
                return(Response.FromStream(resultStream, "application/pdf"));
            };
            Delete["/deleteInvoice/{invoiceId}"] = p =>
            {
                try
                {
                    Guid _id = Guid.Parse(p.invoiceId);
                    this.InvoiceService().Delete(_id, this.CurrentAccount().OwnerId);
                }
                catch (Exception ex)
                {
                    return(Response.AsJson(new { error = true, message = ex.Message }));
                }
                return(Response.AsJson("OK"));
            };
            Get["/SearchInvoice/{key}"] = p =>
            {
                string                       key           = p.key;
                IList <Invoices>             invoices      = new List <Invoices>();
                IEnumerable <InvoiceReports> invoiceReport = this.InvoicesQueryRepository().Search(this.CurrentAccount().OwnerId, new string[] { key });
                foreach (InvoiceReports invoice in invoiceReport)
                {
                    invoices.Add(this.InvoicesRepository().Get(invoice._id, invoice.OwnerId));
                }
                return(Response.AsJson(invoices));
            };
            Post["/UpdateInvoice"] = p =>
            {
                try
                {
                    this.InvoiceService().Update(this.Request.Form.invoice, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(new { error = false }));
                }
                catch (Exception ex)
                {
                    return(Response.AsJson(new { error = true, message = ex.Message }));
                }
            };
            Get["/invoice/{id}"] = p =>
            {
                Guid     invoiceId = p.id;
                Invoices invoice   = this.InvoicesQueryRepository().FindById(invoiceId, this.CurrentAccount().OwnerId);
                return(Response.AsJson(invoice));
            };
            Post["/approveinvoice/{id}"] = p =>
            {
                try
                {
                    Guid invoiceId = p.id;
                    this.InvoiceService().ApproveInvoice(p.id, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(new { error = false }));
                }
                catch (Exception e)
                {
                    return(Response.AsJson(new { error = true, message = e.Message }));
                }
            };

            Get["/InvoiceAutoNumber"] = p =>
            {
                var autoNumber = this.InvoiceAutoNumberGenerator().GetInvoiceAutoNumberConfig(this.CurrentAccount().OwnerId);
                return(Response.AsJson(new { prefix = autoNumber.Prefix, mode = autoNumber.Mode }));
            };
            Post["/SetupInvoiceAutoNumber"] = p =>
            {
                try
                {
                    string Data = this.Request.Form.data;
                    InvoiceAutoNumberConfig config = Newtonsoft.Json.JsonConvert.DeserializeObject <InvoiceAutoNumberConfig>(Data);
                    this.InvoiceAutoNumberGenerator().SetupInvoiceAutoMumber(config.Mode, config.Prefix, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(new { error = false }));
                }
                catch (Exception ex)
                {
                    return(Response.AsJson(new { error = true, message = ex.Message }));
                }
            };

            Post["/cancelinvoice/{id}"] = p =>
            {
                try
                {
                    this.InvoiceService().Cancel(p.id, this.Request.Form.Note, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(new { error = false }));
                }
                catch (Exception e)
                {
                    return(Response.AsJson(new { error = true, message = e.Message }));
                }
            };

            Post["/forcecancelinvoice/{id}"] = p =>
            {
                try
                {
                    this.InvoiceService().ForceCancel(p.id, this.Request.Form.Note, this.CurrentAccount().OwnerId);
                    return(Response.AsJson(new { error = false }));
                }
                catch (Exception e)
                {
                    return(Response.AsJson(new { error = true, message = e.Message }));
                }
            };
        }