How to Convert Rich Text Format to PDF

by Chaknith Bin

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.


C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

C# NuGet Library for PDF

Install with NuGet

Install-Package IronPdf
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer

Check out IronPDF on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming PDF with C#.

C# NuGet Library for PDF nuget.org/packages/IronPdf/
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 DLL

Convert 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")
VB   C#

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

Open RTF file on 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")
VB   C#

Output PDF

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.