Download the dll of pdfsharp from here http://pdfsharp.codeplex.com/releases/view/37054
try
{
string textBoxText;
System.IO.TextReader readFile = new StreamReader("Text.txt");
int yPoint = 0;
PdfDocument pdf = new PdfDocument();
pdf.Info.Title = "TXT to PDF";
PdfPage pdfPage = pdf.AddPage();
XGraphics graph = XGraphics.FromPdfPage(pdfPage);
XFont font = new XFont("Verdana", 20, XFontStyle.Regular );
while (true)
{
if (string.IsNullOrEmpty("textBoxText"))
{
graph.DrawString(line, font, XBrushes.Black, new XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
yPoint = yPoint + 40;
}
}
string pdfFileName = "MyPdfFile.pdf";
pdf.Save(pdfFileName);
readFile.Close();
readFile = null;
Process.Start(pdfFileName);
}
catch(Exception ex)
{
}