With the RTF to PDF Converter library for .NET you can easily convert RTF strings and RTF files to PDF documents. You can convert the RTF document to a PDF document in a memory buffer or to a PDF file. The integration is extremely easy and no other third party tools are necessary to be installed.
The library is distributed as a simple .NET assembly that you reference in your applications. Samples and documentation are available in the downloadable software package.
Default.aspx.csC#
protected void btnConvert_Click(object sender, EventArgs e)
{
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;
pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
pdfConverter.PdfDocumentOptions.ShowFooter = false;
pdfConverter.PdfDocumentOptions.ShowHeader = false;
byte[] downloadBytes = pdfConverter.GetPdfBytesFromRtfString(MyRTFString);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.Clear();
response.AddHeader("Content-Type", "binary/octet-stream");
response.AddHeader(
"Content-Disposition",
"attachment; filename=" + "Rendered.pdf" + "; size="
+ downloadBytes.Length.ToString());
response.Flush();
response.BinaryWrite(downloadBytes);
response.Flush();
response.End();
}