Converts RTF string into array of PDF bytes.

Namespace:  SautinSoft
Assembly:  PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 6.7.12.19

Syntax

      
 C#  Visual Basic 
public byte[] RtfToPdfConvertByte(
	string inputString
)
Public Function RtfToPdfConvertByte ( _
	inputString As String _
) As Byte()

Parameters

inputString
String
RTF document as string

Return Value

PDF document as byte array, or null in case of converting failed.

Examples

CopyHow to convert RTF string to PDF bytes using C# in memory
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

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

            // Specify some options.
            p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape;

            // Specify page numbers.
            p.PageSettings.Numbering.Text = "Page {page} of {numpages}";

            if (p != null)
            {
                string rtfPath = @"..\..\..\..\..\test.rtf";
                string pdfPath = Path.ChangeExtension(rtfPath, ".pdf");
                byte[] rtfBytes = File.ReadAllBytes(rtfPath);


                //2. Converting RTF to PDF
                byte[] pdfBytes = p.RtfToPdfConvertByte(rtfBytes);

                if (pdfBytes != null)
                {
                    //3. Save the PDF document to a file for a viewing purpose.
                    File.WriteAllBytes(pdfPath, pdfBytes);
                    System.Diagnostics.Process.Start(pdfPath);
                }
                else
                {
                    System.Console.WriteLine("An error occured during converting RTF to PDF!");
                }
            }
        }
    }
}
CopyHow to convert RTF string PDF bytes using VB.Net in memory
Imports System
Imports System.IO
Imports System.Collections

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            Dim p As New SautinSoft.PdfMetamorphosis()

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


            ' Specify some options.
            p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape

            ' Specify page numbers.
            p.PageSettings.Numbering.Text = "Page {page} of {numpages}"

            If p IsNot Nothing Then
                Dim rtfPath As String = "..\..\..\..\..\test.rtf"
                Dim pdfPath As String = Path.ChangeExtension(rtfPath, ".pdf")
                Dim rtfBytes() As Byte = File.ReadAllBytes(rtfPath)


                '2. Converting RTF to PDF
                Dim pdfBytes() As Byte = p.RtfToPdfConvertByte(rtfBytes)

                If pdfBytes IsNot Nothing Then
                    '3. Save the PDF document to a file for a viewing purpose.
                    File.WriteAllBytes(pdfPath, pdfBytes)
                    System.Diagnostics.Process.Start(pdfPath)
                Else
                    System.Console.WriteLine("An error occured during converting RTF to PDF!")
                End If
            End If
        End Sub
    End Class
End Namespace

See Also