Converts a Text string into array of PDF bytes.

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

Syntax

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

Parameters

inputString
String
Text document as string

Return Value

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

Remarks

Examples

CopyHow to convert Text 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";

            if (p != null)
            {
                string textPath = @"..\..\..\..\..\test.txt";
                string pdfPath = Path.ChangeExtension(textPath, ".pdf");
                string textString = File.ReadAllText(textPath);


                // 2. Convert Text to PDF in memory                
                byte[] pdfBytes = p.TextToPdfConvertByte(textString);

                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 Text to PDF!");
                }
            }
        }
    }
}
CopyHow to convert Text 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";


            If p IsNot Nothing Then
                Dim textPath As String = "..\..\..\..\..\test.txt"
                Dim pdfPath As String = Path.ChangeExtension(textPath, ".pdf")
                Dim textString As String = File.ReadAllText(textPath)


                ' 2. Convert Text to PDF in memory                
                Dim pdfBytes() As Byte = p.TextToPdfConvertByte(textString)

                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 Text to PDF!")
                End If
            End If
        End Sub
    End Class
End Namespace

See Also