горизонтально расположенные полосы: белая, синяя, красная

Как настроить конвертирование на C# и VB.NET

using System;
using System.IO;
namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Add a page header and footer during the conversion of HTML to RTF or DOCX.
            // If you need more information about "HTML to RTF .Net" email us at:
            // [email protected]
            AddHeaderAndFooter();
        }
        public static void AddHeaderAndFooter()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

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

            string inputFile = @"..\..\sample.html";
            string outputFile = Path.ChangeExtension(inputFile, ".docx");

            // Set page header and footer.
            string headerFromHtml = File.ReadAllText(@"..\..\header.html");
            string footerFromRtf = File.ReadAllText(@"..\..\footer.rtf");

            // Add page header.
            h.PageStyle.PageHeader.Html(headerFromHtml);

            // Add extra space between header and page contents.
            h.PageStyle.PageHeader.MarginBottom.Mm(10);

            // Add page footer.
            h.PageStyle.PageFooter.Rtf(footerFromRtf);
            if (h.OpenHtml(inputFile))
            {
                bool ok = h.ToDocx(outputFile);

                // Open the result for demonstration purposes.
                if (ok)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true });
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Text
Module Module1
    Sub Main()
        ' Add a page header and footer during the conversion of HTML to RTF or DOCX.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' [email protected]
        AddHeaderAndFooter()
    End Sub
    Public Sub AddHeaderAndFooter()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"

        Dim inputFile As String = "..\sample.html"
        Dim outputFile As String = Path.ChangeExtension(inputFile, ".docx")

        ' Set page header and footer.
        Dim headerFromHtml As String = File.ReadAllText("..\header.html")
        Dim footerFromRtf As String = File.ReadAllText("..\footer.rtf")

        ' Add page header.
        h.PageStyle.PageHeader.Html(headerFromHtml)

        ' Add extra space between header and page contents.
        h.PageStyle.PageHeader.MarginBottom.Mm(10)

        ' Add page footer.
        h.PageStyle.PageFooter.Rtf(footerFromRtf)
        If h.OpenHtml(inputFile) Then
            Dim ok As Boolean = h.ToDocx(outputFile)

            ' Open the result for demonstration purposes.
            If ok Then
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outputFile) With {.UseShellExecute = True})
            End If
        End If
    End Sub
End Module

Добавление нумерации страниц

using System;
using System.IO;

namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Add page numbering during to HTML to RTF conversion.
            // If you need more information about "HTML to RTF .Net" email us at:
            // [email protected]
            AddPageNumbering();
        }
        public static void AddPageNumbering()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

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

            string inputFile = @"..\..\sample.html";
            string outputFile = Path.ChangeExtension(inputFile, ".rtf");

            // Add page numbering.
            // Let's set page numbers from 1st page
            h.PageStyle.PageNumbers.Appearance = SautinSoft.HtmlToRtf.ePageNumberingAppearence.PageNumFirst;

            // Lest's align page numbers by top-center
            h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Top;
            h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center;

            // Lest's set page numbers format as "Page 1 of 20".
            h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}";

            // Set page numbers font: Calibry, 36.
            h.PageStyle.PageNumbers.Font.Face = SautinSoft.HtmlToRtf.eFontFace.f_Calibri;
            h.PageStyle.PageNumbers.Font.Size = 36;
            if (h.OpenHtml(inputFile))
            {
                bool ok = h.ToDocx(outputFile);
                // Open the result for demonstration purposes.
                if (ok)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true });
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Add page numbering during to HTML to RTF conversion.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' [email protected]
        AddPageNumbering()
    End Sub
    Public Sub AddPageNumbering()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"

        Dim inputFile As String = "..\sample.html"
        Dim outputFile As String = Path.ChangeExtension(inputFile, ".rtf")

        ' Add page numbering.
        ' Let's set page numbers from 1st page
        h.PageStyle.PageNumbers.Appearance = SautinSoft.HtmlToRtf.ePageNumberingAppearence.PageNumFirst

        ' Lest's align page numbers by top-center
        h.PageStyle.PageNumbers.AlignV = SautinSoft.HtmlToRtf.eAlign.Top
        h.PageStyle.PageNumbers.AlignH = SautinSoft.HtmlToRtf.eAlign.Center

        ' Lest's set page numbers format as "Page 1 of 20".
        h.PageStyle.PageNumbers.Format = "Page {page} of {numpages}"

        ' Set page numbers font: Calibry, 36.
        h.PageStyle.PageNumbers.Font.Face = SautinSoft.HtmlToRtf.eFontFace.f_Calibri
        h.PageStyle.PageNumbers.Font.Size = 36
        If h.OpenHtml(inputFile) Then
            Dim ok As Boolean = h.ToDocx(outputFile)

            ' Open the result for demonstration purposes.
            If ok Then
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outputFile) With {.UseShellExecute = True})
            End If
        End If
    End Sub
End Module

Установка языка для орфографических инструментов

using System;
using System.IO;
namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Set a language for a spelling tools.
            // If you need more information about "HTML to RTF .Net" email us at:
            // [email protected]
            ConvertHtmlToRtfFile();
        }
        public static void ConvertHtmlToRtfFile()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

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

            string inputFile = @"..\..\sample.html";
            string outputFile = Path.ChangeExtension(inputFile, ".rtf");

            // Set a language for a spelling tools.
            h.RtfLanguage = SautinSoft.HtmlToRtf.eRtfLanguage.l_EnglishUK;
            if (h.OpenHtml(inputFile))
            {
                bool ok = h.ToRtf(outputFile);

                // Open the result for demonstration purposes.
                if (ok)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true });
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Set a language for a spelling tools.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' [email protected]
        ConvertHtmlToRtfFile()
    End Sub
    Public Sub ConvertHtmlToRtfFile()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"

        Dim inputFile As String = "..\sample.html"
        Dim outputFile As String = Path.ChangeExtension(inputFile, ".rtf")

        ' Set a language for a spelling tools.
        h.RtfLanguage = SautinSoft.HtmlToRtf.eRtfLanguage.l_EnglishUK
        If h.OpenHtml(inputFile) Then
            Dim ok As Boolean = h.ToRtf(outputFile)

            ' Open the result for demonstration purposes.
            If ok Then
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outputFile) With {.UseShellExecute = True})
            End If
        End If
    End Sub
End Module

Установка размера страницы и полей

using System;
using System.IO;
namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Set page size A5; margins: top, bottom 30 mm and left, right to 50 mm.
            // If you need more information about "HTML to RTF .Net" email us at:
            // [email protected]
            ConvertHtmlToDocxFile();
        }
        public static void ConvertHtmlToDocxFile()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

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

            string inputFile = @"..\..\sample.html";
            string outputFile = Path.ChangeExtension(inputFile, ".docx");

            // Set page size and page margins.
            h.PageStyle.PageSize.A5();
            h.PageStyle.PageMarginTop.Mm(30);
            h.PageStyle.PageMarginBottom.Mm(30);
            h.PageStyle.PageMarginLeft.Mm(50);
            h.PageStyle.PageMarginRight.Mm(50);

            if (h.OpenHtml(inputFile))
            {
                bool ok = h.ToDocx(outputFile);

                // Open the result for demonstration purposes.
                if (ok)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true });
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Set page size A5; margins: top, bottom 30 mm and left, right to 50 mm.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' [email protected]
        ConvertHtmlToDocxFile()
    End Sub
    Public Sub ConvertHtmlToDocxFile()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"

        Dim inputFile As String = "..\sample.html"
        Dim outputFile As String = Path.ChangeExtension(inputFile, ".docx")

        ' Set page size and page margins.
        h.PageStyle.PageSize.A5()
        h.PageStyle.PageMarginTop.Mm(30)
        h.PageStyle.PageMarginBottom.Mm(30)
        h.PageStyle.PageMarginLeft.Mm(50)
        h.PageStyle.PageMarginRight.Mm(50)

        If h.OpenHtml(inputFile) Then
            Dim ok As Boolean = h.ToDocx(outputFile)

            ' Open the result for demonstration purposes.
            If ok Then
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outputFile) With {.UseShellExecute = True})
            End If
        End If
    End Sub
End Module

Установка одного семейства шрифтов, размера и цвета

using System;
using System.IO;
namespace Sample
{
    class Test
    {
        static void Main(string[] args)
        {
            // Set single font family, size and color.
            // If you need more information about "HTML to RTF .Net" email us at:
            // [email protected]
            SetSingleFontProperties();
        }
        /// <summary>
        /// Converts HTML to DOCX and sets the uniform Font Family, Size and Color for all text.
        /// </summary>
        public static void SetSingleFontProperties()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            // After purchasing the license, please insert your serial number here to activate the component.
            // h.Serial = "XXXXXXXXX";
            string inputFile = @"..\..\sample.html";
            string outputFile = Path.ChangeExtension(inputFile, ".docx");

            // Let's make all text in document the same: Calibri, 32pt, Gray.
            h.TextStyle.SingleFontFamily = SautinSoft.HtmlToRtf.eFontFace.f_Calibri;
            h.TextStyle.SingleFontSize = 32;
            h.TextStyle.SingleFontColor = System.Drawing.Color.Gray;

            if (h.OpenHtml(inputFile))
            {
                bool ok = h.ToDocx(outputFile);
                // Open the result for demonstration purposes.
                if (ok)
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true });
            }
        }
    }
}
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Set single font family, size and color.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' [email protected]
        SetSingleFontProperties()
    End Sub
    ' Converts HTML to DOCX and sets the uniform Font Family, Size and Color for all text.
    Public Sub SetSingleFontProperties()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"

        Dim inputFile As String = "..\sample.html"
        Dim outputFile As String = Path.ChangeExtension(inputFile, ".docx")

        ' Let's make all text in document the same: Calibri, 32pt, Gray.
        h.TextStyle.SingleFontFamily = SautinSoft.HtmlToRtf.eFontFace.f_Calibri
        h.TextStyle.SingleFontSize = 32
        h.TextStyle.SingleFontColor = System.Drawing.Color.Gray

        If h.OpenHtml(inputFile) Then
            Dim ok As Boolean = h.ToDocx(outputFile)

            ' Open the result for demonstration purposes.
            If ok Then
                System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outputFile) With {.UseShellExecute = True})
            End If
        End If
    End Sub
End Module

Другие примеры кода SautinSoft.HtmlToRtf

HTML в RTF HTML в DOCX HTML в Text Слияние/Замена RTF ✦ Настройки
 ВВЕРХ