RTF to PDF
from ironpdf import *

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Either load your RTF file directly
pdf_from_rtf_file = renderer.RenderRtfFileAsPdf("/files/doc.rtf")

# Or instead, load it as a string
pdf_from_rtf_string = renderer.RenderRtfStringAsPdf(r"{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}{\colortbl;\red0\green0\blue0;}\cf0This is some \b bold \b0 and \i italic \i0 text.}")

# Save your PDF
pdf_from_rtf_file.SaveAs("pdf_from_rtf_file.pdf")
pdf_from_rtf_string.SaveAs("pdf_from_rtf_string.pdf")
pip install ironpdf
RTF to PDF

RTF to PDF

IronPDF for Python can convert Rich Text Format (RTF) documents into PDFs directly from a file path or from an in-memory RTF string.

Getting Started

Use ChromePdfRenderer and call one of two methods depending on your input source:

  • RenderRtfFileAsPdf(path): Accepts a file path to a .rtf file and returns a PdfDocument.
  • RenderRtfStringAsPdf(rtf_string): Accepts a raw RTF-formatted string and returns a PdfDocument.

Both methods produce a PdfDocument object that can be saved, merged, stamped, or further modified using IronPDF's full editing API.

Understanding the Code

  • RenderRtfFileAsPdf: Reads the RTF file from disk and converts its content - including fonts, bold, italic, and color formatting - into a faithful PDF representation.
  • RenderRtfStringAsPdf: Allows RTF content to be passed directly as a Python string, removing the need to write a temporary file to disk first.
  • SaveAs: Writes the resulting PdfDocument to the specified output path.

RTF String Format

RTF strings use a markup syntax like {\rtf1\ansi ... }. Bold text is wrapped with \b ... \b0 and italic with \i ... \i0. Standard font and color table declarations must be present for correct rendering.

Learn more about PDF generation with IronPDF for Python!

Ready to Get Started?

Version:2026.11just released