Exemple #1
0
        private void button7_Click(object sender, EventArgs e)
        {
            SaveFileDialog MyFiles = new SaveFileDialog();

            MyFiles.Filter     = "PDF File (*.pdf)|*.pdf|HTML File (*.html)|*.html";
            MyFiles.Title      = "Save As...";
            MyFiles.DefaultExt = "*.pdf";
            MyFiles.FileName   = ReportCombo.Text.Replace(" ", "_").Replace("/", "");;
            if (MyFiles.ShowDialog() == DialogResult.OK)
            {
                string name = MyFiles.FileName;
                string ext  = Path.GetExtension(name);
                if (string.Compare(".pdf", ext, true) == 0)
                {
                    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
                    htmlToPdfConverter.LicenseKey      = "sjwvPS4uPSskPSgzLT0uLDMsLzMkJCQk";
                    htmlToPdfConverter.HtmlViewerWidth = 850;
                    htmlToPdfConverter.PdfDocumentOptions.AvoidImageBreak = true;
                    htmlToPdfConverter.ConvertHtmlToFile(winFormHtmlEditor1.DocumentHtml, "", name);
                }
                else
                {
                    File.WriteAllText(name, winFormHtmlEditor1.DocumentHtml);
                }
            }
        }
Exemple #2
0
        public static int ConvertToPdf(string html_string, string name)
        {
            int retval = 0;

            try
            {
                string             body      = "";
                HtmlToPdfConverter converter = GetInitializedHtmlConverter(html_string, out body);
                converter.ConvertHtmlToFile(body, "", name);
            }
            catch (Exception e)
            {
                retval = 1;
                Logger.Instance.WriteToLog(e.ToString());
            }

            return(retval);
        }
Exemple #3
0
 private void button7_Click(object sender, EventArgs e)
 {
     SaveFileDialog MyFiles = new SaveFileDialog();
     MyFiles.Filter = "PDF File (*.pdf)|*.pdf|HTML File (*.html)|*.html";
     MyFiles.Title = "Save As...";
     MyFiles.DefaultExt = "*.pdf";
     MyFiles.FileName = ReportCombo.Text.Replace(" ", "_").Replace("/", ""); ;
     if (MyFiles.ShowDialog() == DialogResult.OK)
     {
         string name = MyFiles.FileName;
         string ext = Path.GetExtension(name);
         if (string.Compare(".pdf",ext,true)==0)
         {
             HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
             htmlToPdfConverter.LicenseKey = "sjwvPS4uPSskPSgzLT0uLDMsLzMkJCQk";
             htmlToPdfConverter.HtmlViewerWidth = 850;
             htmlToPdfConverter.PdfDocumentOptions.AvoidImageBreak = true;
             htmlToPdfConverter.ConvertHtmlToFile(winFormHtmlEditor1.DocumentHtml, "", name);
         }
         else
         {
             File.WriteAllText(name, winFormHtmlEditor1.DocumentHtml);
         }
     }
 }