PdfMetamorphosisRtfToPdfConvertStringToFile Method |
Converts RTF string to PDF file.
Namespace: SautinSoftAssembly: PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 2024.12.19
Syntaxpublic int RtfToPdfConvertStringToFile(
string inputString,
string outputFileName
)
Public Function RtfToPdfConvertStringToFile (
inputString As String,
outputFileName As String
) As Integer
Parameters
- inputString String
- RTF document as string
- outputFileName String
- Local path to output PDF file
Return Value
Int32
0 - converting successfully
2 - can't create output file, check the output path
3 - converting failed
ExampleHow to convert RTF string to PDF file in C#
using System;
using System.IO;
using System.Collections;
namespace Sample
{
class Test
{
static void Main(string[] args)
{
SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();
if (p != null)
{
string rtfPath = @"..\..\..\example.rtf";
string pdfPath = Path.ChangeExtension(rtfPath,".pdf");
string rtfString = File.ReadAllText(rtfPath);
if (p.RtfToPdfConvertStringToFile(rtfString,pdfPath)==0)
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true });
else
System.Console.WriteLine("An error occurred during converting RTF to PDF!");
}
}
}
}
How to convert RTF string to PDF file in VB.Net
Imports System.IO
Namespace Sample
Friend Class Test
Shared Sub Main(ByVal args() As String)
Dim p As New SautinSoft.PdfMetamorphosis()
If p IsNot Nothing Then
Dim rtfPath As String = "..\..\..\example.rtf"
Dim pdfPath As String = Path.ChangeExtension(rtfPath, ".pdf")
Dim rtfString As String = File.ReadAllText(rtfPath)
If p.RtfToPdfConvertStringToFile(rtfString, pdfPath) = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pdfPath) With {.UseShellExecute = True})
Else
System.Console.WriteLine("An error occurred during converting RTF to PDF!")
End If
End If
End Sub
End Class
End Namespace
See Also