Set header/footer from any HTML string

Namespace:  SautinSoft
Assembly:  SautinSoft.HtmlToRtf (in SautinSoft.HtmlToRtf.dll) Version: 5.8.2.8

Syntax

      
 C#  Visual Basic 
public void Html(
	string html
)
Public Sub Html ( _
	html As String _
)

Parameters

html
String
String in HTML format

Remarks

We don't recommend to use complex HTML documents as header or footer. The best is using simple HTML table with text and images as header/footer.



Examples

CopyASP.Net - Convert ASPX page to RTF using C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Result.Text = "";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();
        //After purchasing the license, please insert your serial number here to activate the component
        //h.Serial = "XXXXXXXXXXXXXXX";

        h.PageStyle.PageSize.Letter();
        h.PageStyle.PageMarginLeft.Mm(25);

        string rtf = h.ConvertFileToString(Path.Combine(Server.MapPath(""), @"Default.aspx"));

        //show Word/rtf
        if (rtf != "")
        {
            Response.Clear();
            Response.ContentType = "application/msword";
            Response.AddHeader("content-disposition", "inline; filename=\"Result.doc\"");
            byte[] data = System.Text.Encoding.UTF8.GetBytes(rtf);
            Response.BinaryWrite(data);
            Response.Flush();
            Response.End();
        }
        else
        {
            Result.Text = "Converting failed!";
        }
    }
}
CopyASP.Net - Convert ASPX page to RTF using VB.Net
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO
Imports System.Net

Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Result.Text = ""
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim h As New SautinSoft.HtmlToRtf()
        'After purchasing the license, please insert your serial number here to activate the component
        'h.Serial = "XXXXXXXXXXXXXXX";


        h.PageStyle.PageSize.Letter()
        h.PageStyle.PageMarginLeft.Mm(25)

        Dim rtf As String = h.ConvertFileToString(Path.Combine(Server.MapPath(""), "Default.aspx"))

        'show Word/rtf
        If rtf <> "" Then
            Response.Clear()
            Response.ContentType = "application/msword"
            Response.AddHeader("content-disposition", "inline; filename=""Result.doc""")
            Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(rtf)
            Response.BinaryWrite(data)
            Response.Flush()
            Response.End()
        Else
            Result.Text = "Converting failed!"
        End If
    End Sub
End Class

See Also