Exemplo n.º 1
0
        public ReponseConvertToPDF ConvertHtmlToPdf(string sHtml)
        {
            ReponseConvertToPDF reponseConvertToPDF = new ReponseConvertToPDF()
            {
                sMessage = "ConvertHtmlToPdf : " + sInitLog
            };
            string message = "";

            try {
                DateTime dtNow            = DateTime.Now;
                string   Sufixe           = dtNow.DayOfYear.ToString() + "_" + dtNow.Hour.ToString() + "_" + dtNow.Minute.ToString() + "_" + dtNow.Second.ToString();
                string   sFileBase        = sPathDirectory + "\\HtmlToPdf\\base" + Sufixe + ".html";
                string   sFileResultat    = sPathDirectory + "\\HtmlToPdf\\resultat" + Sufixe + ".pdf";
                string   sFileResultatWEB = "HtmlToPdf/resultat" + Sufixe + ".pdf";
                //string sFilecss = sPathDirectory + "\\HtmlToPdf\\CssFile.css";
                File.AppendAllText(sFileBase, sHtml);
                // convert a HTML document into a PDF file
                //prn.AddStyleSheet(sFilecss);
                prn.Convert(sFileBase, sFileResultat);
                reponseConvertToPDF.sFileResultat = sFileResultatWEB;
                SingleLogFileAsXml.Instance().AjouteLog("Pdf", "SingleConvertToPDF. ConvertHtmlToPdf : " + sFileResultatWEB);
            }
            catch (Exception ex) {
                message = ex.Message;
                SingleLogFileAsXml.Instance().AjouteLog("Pdf", "SingleConvertToPDF. ConvertHtmlToPdf : Exception : " + ex.Message);
            }
            return(reponseConvertToPDF);
        }
Exemplo n.º 2
0
        public ReponseConvertToPDF TestConvertHtmlToPdf(string Sender, string sHtml)
        {
            ReponseConvertToPDF reponseConvertToPDF = new ReponseConvertToPDF()
            {
                sMessage = "ConvertHtmlToPdf : " + sInitLog, Sender = Sender + "/" + sHtml
            };
            string message = "";

            try {
                string sFileBase     = sPathDirectory + "\\HtmlToPdf\\Test1.html";
                string sFileResultat = sPathDirectory + "\\HtmlToPdf\\resultatTest1.pdf";
                // convert a HTML document into a PDF file
                prn.Convert(sFileBase, sFileResultat);
                reponseConvertToPDF.sFileResultat = "HtmlToPdf/resultatTest1.pdf";
            }
            catch (Exception ex) {
                message = ex.Message;
                SingleLogFileAsXml.Instance().AjouteLog("Pdf", "SingleConvertToPDF. ConvertHtmlToPdf : Exception : " + ex.Message);
            }
            return(reponseConvertToPDF);
        }