Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active March 16, 2022 14:21
How to Convert RTF to PDF using C#. For more information, please follow link: https://kb.aspose.com/words/net/how-to-convert-rtf-to-pdf-using-c-sharp/
using System;
using Aspose.Words;
using Aspose.Words.Saving;
namespace WordKB
{
public class ConvertRtfToPdfUsingCSharp
{
public static void Main2(string[] args)
{
Load the license to avoid trial version watermark in the converted PDF from RTF
License RtfToPdfLicense = new License();
RtfToPdfLicense.SetLicense("Aspose.Word.lic");
// Load the source input RTF file
Document inputRtfFile = new Document("InputSampleRtf.rtf");
// Create and initialize PdfSaveOptions to customize the output PDF file
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
// Set color mode for rendering the contents
pdfSaveOptions.ColorMode = ColorMode.Grayscale;
// Save the converted PDF file from RTF
inputRtfFile.Save("OutputRtfAsPdf.pdf", pdfSaveOptions);
System.Console.WriteLine("Done");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment