Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string html = string.Empty;
                if (TemplateValidatorHelper.IsValidXslt(textBox1.Text))
                {
                    html = TemplateValidatorHelper.GetTransformedXslt(textBox1.Text);
                }
                else
                {
                    html = textBox1.Text;
                }
                byte[] bytes = TemplateValidatorHelper.GetPdfFromHtml(html);

                var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                var fullFileName  = Path.Combine(desktopFolder, "test.pdf");
                var fs            = new FileStream(fullFileName, FileMode.Create);
                fs.Write(bytes, 0, bytes.Length);
                fs.Close();

                MessageBox.Show("PDF was created and saved to your desktop.  It will be opened when you click OK", "PDF Created",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);

                System.Diagnostics.Process.Start(fullFileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error Creating PDF: {0}", ex.Message), "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (TemplateValidatorHelper.IsValidXslt(textBox1.Text))
     {
         MessageBox.Show("The attached HTML is valid XSLT", "Valid",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("The attached HTML is NOT valid XSLT", "Invalid",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
 public void TestGetTemplateTypes()
 {
     Assert.IsTrue(TemplateValidatorHelper.IsValidXslt("<html></html"));
 }