private void createPDF() { openFileDialog.Filter = "HTML Files (.html)|*.html"; openFileDialog.FilterIndex = 0; if (openFileDialog.ShowDialog() == DialogResult.OK) { System.Text.StringBuilder store = new System.Text.StringBuilder(); string fileName = openFileDialog.FileName; try { using (System.IO.StreamReader htmlReader = new System.IO.StreamReader(openFileDialog.FileName)) { string line; while ((line = htmlReader.ReadLine()) != null) { store.Append(line + Environment.NewLine); } this.textBox1.Text = store.ToString(); string html = store.ToString(); Document document = new Document(PageSize.LETTER, 20, 25, 35, 35); PdfWriter.GetInstance(document, new FileStream("c:\\Data/my.pdf", FileMode.Create)); document.Open(); System.Collections.Generic.List<IElement> htmlarraylist = new List<IElement>(HTMLWorker.ParseToList(new StringReader(html), new StyleSheet())); foreach (IElement element in htmlarraylist) { document.Add(element); } document.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)