How to convert RTF to PDF in C#, VB.Net and ASP.Net?

PDF Metamorphosis .Net

.Net assembly which gives API to convert RTF, Text, HTML, DOCX to PDF in .Net and C#.
How to convert RTF to PDF in C#, VB.Net and ASP.Net?

PDF Metamorphosis .Net

How to convert RTF to PDF in C#, VB.Net and ASP.Net?
How to convert RTF to PDF in C#, VB.Net and ASP.Net?

Introduction

With the help of "PDF Metamorphosis .Net", any .NET application can easily transform RTF documents to PDF format. For example, to convert a RTF to PDF in C# you will only need to add a reference to the PdfMetamorphosis.dll and type a few lines of code:


            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

string rtfPath = @"c:\Crime and Punishment.rtf";
string pdfPath = @"c:\Crime and Punishment.pdf";

p.RtfToPdfConvertFile(rtfPath, pdfPath);
          

The library gives you a full set of API to convert RTF to PDF and completely retains the document structure. Furthermore, during conversion to PDF you may adjust following:

  • Set page size, orientation and margins.
  • Set a single font face, size and color for your PDF document.
  • Add custom headers and footers.
  • Add page numbering.
  • Add custom watermarks to your PDF.
  • Specify the version of produced PDF.
  • Embed all fonts inside PDF.

Download

To see this functionality firsthand, download the freshest «PDF Metamorphosis .Net» with code examples, 39.6 Mb.

Limitations

PDF Metamorphosis .Net The limitations of the free version are: The trial notice "Created by unlicensed version of PDF Metamorphosis .Net" and the random addition of the word "TRIAL".


Input RTF documents

The component can read and parse all types of RTF documents: 1.0 - 1.9.1. The component has own RTF parser. If you are looking only for C# RTF class which can parse and render RTF documents, see Document .Net.

Output PDF documents

PDF Metamorphosis .NET can render PDF documents using own PDF class. You may select the version for output PDF: 1.3 -1.7, PDF/A. If you are looking for .Net class (C#) to convert PDF to other formats, see our PDF Focus .Net.


Some examples to convert RTF to PDF in C# and VB.Net

1. Convert RTF file to PDF file in C#:

            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            if (p != null)
            {
                string rtfPath = @"d:\Anna Karenina.rtf";
                string pdfPath = Path.ChangeExtension(rtfPath, ".pdf");

                if (p.RtfToPdfConvertFile(rtfPath, pdfPath)==0)
                {
                    System.Diagnostics.Process.Start(pdfPath);
                }
            }
      
2. Convert RTF to PDF in memory using C#:
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            if (p != null)
            {
                string rtfPath = @"d:\Anna Karenina.rtf";
                string rtfString = File.ReadAllText(rtfPath);

                p.PageSettings.Size.A5();

                byte[] pdfBytes = p.RtfToPdfConvertByte(rtfString);
            }
      
3. Convert RTF to PDF and add custom header & footer using C#:
            // How to add page header and footer
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            // Add custom header in HTML format.
            string headerInHtml = "
You are welcome!
"; p.PageSettings.Header.Html(headerInHtml); // Add customer footer in RTF format. string footerInRtf = @"{\i Italic Header}"; p.PageSettings.Footer.Rtf(footerInRtf); string rtfFile = @"c:\The Brothers Karamazov.rtf"; string pdfFile = Path.ChangeExtension(rtfFile, ".pdf"); int result = p.RtfToPdfConvertFile(rtfFile, pdfFile);
4. Export RTF to PDF, set the single font, embed the font in PDF - VB.Net:
            ' How to set a single font for the whole PDF document.
            Dim p As New SautinSoft.PdfMetamorphosis()

            ' After purchasing the license, please insert your serial number here to activate the component
            'p.Serial = "XXXXXXXXXXX";

            ' Let's make that the all text in PDF became in 'Courier New' font
            p.TextSettings.FontFace.Custom("Courier New")
            ' Set also a single font size 10
            p.TextSettings.FontSize = 10
            ' Set also single text color
            p.TextSettings.FontColor = System.Drawing.Color.FromArgb(33, 150, 150)

            ' Embed all fonts inside PDF.
            p.PdfSettings.EmbedAllFonts = True


            Dim rtfPath As String = "c:\War and Peace.rtf"
            Dim pdfPath As String = "c:\War and Peace.pdf"

            Dim result As Integer = p.RtfToPdfConvertFile(rtfPath, pdfPath)
      

Requirements and Technical Information

Requires .NET Framework 4.0 or higher. Our product is compatible with all .NET languages and supports all Operating Systems where .NET Framework and .NET Core can be used. Note that PDF Metamorphosis .Net is entirely written in managed C#, which makes it absolutely standalone and an independent library.

.Net Framework 4.0 and higher and .Net Core 2.0 and higher

.NET Framework 4.0, 4.5, 4.6.1 and higher.

.NET Standard 2.0

.NET Core 2.0 and higher.


Multi-platform component, runs on:


Our component has proven itself on cloud platforms and services:

  • Microsoft Azure
  • Amazon Web Services (AWS)
  • Google Cloud Platform
  • SharePoint
  • Docker
  • etc.

If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: