PdfMetamorphosisHeadersFootersFromFile(String) Method |
Set header/footer from local RTF file
Namespace: SautinSoftAssembly: PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 2024.12.19
Syntax public void FromFile(
string path
)
Public Sub FromFile (
path As String
)
Parameters
- path String
- Path to local RTF file
Remarks This method is very usefull when you want to insert header/footer from existing RTF document.
Example How to add page header and footer using 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 inputFile = @"..\..\..\example.rtf";
string originalPdf = @"..\..\..\Original.pdf";
string customPdf = @"..\..\..\CustomFooter.pdf";
if (p.RtfToPdfConvertFile(inputFile, originalPdf)==0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(originalPdf) { UseShellExecute = true });
}
string footerInHtml = "<table width=\"100%\" border=\"1\"><tr><td width=\"50%\"></td><td>This is new custom footer!</td></tr></table>";
p.PageSettings.Footer.FromString(footerInHtml, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html);
if (p.RtfToPdfConvertFile(inputFile, customPdf) == 0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(customPdf) { UseShellExecute = true });
}
}
}
}
}
How to add page header and footer using VB.Net.
Module sample
Sub Main()
Dim p As New SautinSoft.PdfMetamorphosis()
If p IsNot Nothing Then
Dim inputFile As String = "..\..\..\example.rtf"
Dim originalPdf As String = "..\..\..\Original.pdf"
Dim customPdf As String = "..\..\..\CustomFooter.pdf"
If p.RtfToPdfConvertFile(inputFile, originalPdf) = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(originalPdf) With {.UseShellExecute = True})
End If
Dim footerInHtml As String = "<table width=""100%"" border=""1""><tr><td width=""50%""></td><td>This is new custom footer!</td></tr></table>"
p.PageSettings.Footer.FromString(footerInHtml, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html)
If p.RtfToPdfConvertFile(inputFile, customPdf) = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(customPdf) With {.UseShellExecute = True})
End If
End If
End Sub
End Module
See Also