Rajesh Thiru

Rajesh Thiru

  • NA
  • 101
  • 4.3k

convert word Document to pdf using c#

Jun 17 2019 8:25 AM
Here i have tried so many codings  for convert word Document to Pdf but not working properly (alginment issue)here i mentioned  the code below,
 
//Read the Data from Input File
StreamReader rdr = new StreamReader(txtInput.Text);
//Create a New instance on Document Class
Document doc = new Document();
//Create a New instance of PDFWriter Class for Output File
PdfWriter.GetInstance(doc, new FileStream(txtOutput.Text, FileMode.Create));
//Open the Document
doc.Open();
//Add the content of Text File to PDF File
doc.Add(new Paragraph(rdr.ReadToEnd()));
//Close the Document
doc.Close();
MessageBox.Show("Conversion Successful....");
//Open the Converted PDF File
System.Diagnostics.Process.Start(txtOutput.Text);
 
Kindly suggest some other code without using API and if possible Kindly correct the mistake in my code for alignment issue

Answers (5)