Whatever solution you use to convert RTF to PDF before, the solution that will be introduced is the easiest method to clearly realize your RTF to PDF conversion task. The whole process can be accomplished through three lines of key code in your WPF application via a Word component Spire.Doc for WPF.
Spire.Doc for WPF, different from RTF to PDF converters, is a WPF Word component, which can generate, read, write and modify word documents in your WPF applications. Apart from converting RTF to PDF, Spire.Doc for WPF can convert word to many other commonly used formats such as PDF, HTML, Text, XML, Image and so on. Please first preview the effective screenshot of the target PDF file:
Now, please download Spire.Doc for WPF and convert your RTF to PDF by the code below:
[C#]
using Spire.Doc; namespace WPFRTFtoPDF { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { Document doc = new Document(); doc.LoadFromFile(@"..\WPFRTFtoPDF.rtf", FileFormat.Rtf); doc.SaveToFile("test.pdf", FileFormat.PDF); } } }
[VB.NET]
Imports Spire.Doc Namespace WPFRTFtoPDF Public Partial Class MainWindow Inherits Window Public Sub New() InitializeComponent() End Sub Private Sub button1_Click(sender As Object, e As RoutedEventArgs) Dim doc As New Document() doc.LoadFromFile("..\WPFRTFtoPDF.rtf", FileFormat.Rtf) doc.SaveToFile("test.pdf", FileFormat.PDF) End Sub End Class End Namespace
For comparison, I put the original RTF file below:
Spire.Doc is a standalone word component, which enables users to perform a wide range of word document processing tasks in WPF, .NET and Silverlight without installing MS Word on system.