How to Convert Rich Text Format to PDF
RTF stands for Rich Text Format, a document file format developed by Microsoft. It supports text formatting such as fonts, styles, and images, but is less feature-rich than other document formats like DOCX or PDF.
IronPDF can be utilized to convert RTF from both strings and files to PDF. Converting RTF to PDF offers several benefits, such as being easily accessible, compressible, and optimized for printing. This ensures that your documents look consistent across all platforms, are secure, and are ready for printing.
How to Convert RTF to PDF
- Download the C# library for converting RTF to PDF
- Prepare the RTF file or string you wish to convert
- Use the
RenderRtfStringAsPdf
method to convert from an RTF string - Use the
RenderRtfFileAsPdf
method to convert from an RTF file - Review the generated PDF document
Install with NuGet
Install-Package IronPdf
Download DLL
Manually install into your project
Install with NuGet
Install-Package IronPdf
Download DLL
Manually install into your project
Start using IronPDF in your project today with a free trial.
Check out IronPDF on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming PDF with C#.
Install-Package IronPdf
Consider installing the IronPDF DLL directly. Download and manually install it for your project or GAC form: IronPdf.zip
Manually install into your project
Download DLLConvert RTF String to PDF Example
Use the RenderRtfStringAsPdf
method to transform an RTF string into a PDF document. The full range of RenderingOptions, such as applying text and HTML headers and footers, text and image stamping, page numbering, custom page sizes and orientations, is also applicable to this rendering method. After the PDF document has been generated, you can perform PDF page manipulations like merging, splitting, and rotating pages, as well as applying annotations and bookmarks.
:path=/static-assets/pdf/content-code-examples/how-to/rtf-to-pdf-from-string.cs
using IronPdf;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// RTF string
string rtf = @"{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}{\colortbl;\red0\green0\blue0;}\cf0This is some \b bold \b0 and \i italic \i0 text.}";
// Render from RTF string
PdfDocument pdf = renderer.RenderRtfStringAsPdf(rtf);
// Save the PDF
pdf.SaveAs("pdfFromRtfString.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
' RTF string
Private rtf As String = "{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}{\colortbl;\red0\green0\blue0;}\cf0This is some \b bold \b0 and \i italic \i0 text.}"
' Render from RTF string
Private pdf As PdfDocument = renderer.RenderRtfStringAsPdf(rtf)
' Save the PDF
pdf.SaveAs("pdfFromRtfString.pdf")
Convert RTF File to PDF Example
To transform an RTF file into a PDF, use the RenderRtfFileAsPdf
method. You can download a sample RTF file from the provided link. This example will demonstrate how to convert that sample file into a PDF document.
RTF File Preview in Microsoft Word
Code Sample
:path=/static-assets/pdf/content-code-examples/how-to/rtf-to-pdf-from-file.cs
using IronPdf;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render from RTF file
PdfDocument pdf = renderer.RenderRtfFileAsPdf("sample.rtf");
// Save the PDF
pdf.SaveAs("pdfFromRtfFile.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
' Render from RTF file
Private pdf As PdfDocument = renderer.RenderRtfFileAsPdf("sample.rtf")
' Save the PDF
pdf.SaveAs("pdfFromRtfFile.pdf")