How to Convert Text into PDF Format

This article shows how to convert text into PDF format and a database table take form and ContextMenuStrip


This article shows how to convert text into PDF format and a database table take form and ContextMenuStrip in that Save to PDF and Save to DB and 
also take RichtxtBox and write coding click event.

private void saveToPDFToolStripMenuItem_Click(object sender, EventArgs e)
{
    SaveFileDialog s = new SaveFileDialog();
    s.InitialDirectory = "C:";
    s.Filter = "Pdf file(*.pdf)|*.pdf";

    if (s.ShowDialog() == DialogResult.OK)
    {
        Document Doc = new Document();
        PdfWriter.GetInstance(Doc, new FileStream(s.FileName, FileMode.Create));
        Doc.Open();
        Doc.Add(new Paragraph(richTextBox1.Text));
        Doc.Close();
    }
}
 

private
void saveToDBToolStripMenuItem_Click(object sender, EventArgs e)
{  
         {
                SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=master;User ID=sa;word=coign");
                string s1 = "Insert into Dat values('" + richTextBox1.Text + "')";
                SqlCommand cmd = new SqlCommand(s1, cn);
                cn.Open();
                cmd.ExecuteNonQuery();
                cn.Close();

                MessageBox.Show("save in DB");
            }
}