Leadtools.Forms.DocumentWriters Namespace : RtfDocumentOptions Class |
public class RtfDocumentOptions : DocumentOptions
'Declaration Public Class RtfDocumentOptions Inherits DocumentOptions
'Usage Dim instance As RtfDocumentOptions
public sealed class RtfDocumentOptions : DocumentOptions
function Leadtools.Forms.DocumentWriters.RtfDocumentOptions()
public ref class RtfDocumentOptions : public DocumentOptions
The options set in the RtfDocumentOptions class will be used when the user saves a document using the DocumentFormat.Rtf format.
To change the options used with the RTF format, perform the following steps:
The RtfDocumentOptions class contains the following properties:
Property | Description |
---|---|
RtfDocumentOptions.Framed | Turn off or on the option to put the text blocks inside a frame (text box object) in the resulting RTF file. |
' Windows API functions needed to load/delete an EMF <DllImport("gdi32.dll")> _ Private Shared Function GetEnhMetaFile(ByVal lpszMetaFile As String) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function DeleteEnhMetaFile(ByVal hemf As IntPtr) As Boolean End Function Private Sub RtfDocumentOptionsExample() ' Unlock the support needed for LEADTOOLS Document Writers (with PDF output) RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here") ' Create a new instance of the LEADTOOLS Document Writer Dim docWriter As New DocumentWriter() Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.rtf") Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf") ' Change the RTF options to add frames to the file dim rtfOptions as RtfDocumentOptions = directcast(docWriter.GetOptions(DocumentFormat.Rtf) , RtfDocumentOptions) rtfOptions.Framed = True docWriter.SetOptions(DocumentFormat.Rtf, rtfOptions) ' Create a new RTF document Console.WriteLine("Creating new RTF document: {0}", outputFileName) docWriter.BeginDocument(outputFileName, DocumentFormat.Rtf) ' Use the Windows API to load the EMF Dim emfHandle As IntPtr = GetEnhMetaFile(emfFileName) ' Add the page Dim page As DocumentPage = DocumentPage.Empty page.EmfHandle = emfHandle page.Image = Nothing Console.WriteLine("Adding EMF page from: {0}", emfFileName) docWriter.AddPage(page) ' Use the Windows API to delete the EMF DeleteEnhMetaFile(emfHandle) ' Finally finish writing the RTF file on disk docWriter.EndDocument() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
// Windows API functions needed to load/delete an EMF [DllImport("gdi32.dll")] private static extern IntPtr GetEnhMetaFile(string lpszMetaFile); [DllImport("gdi32.dll")] private static extern bool DeleteEnhMetaFile(IntPtr hemf); private void RtfDocumentOptionsExample() { // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter = new DocumentWriter(); string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.rtf"); string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf"); // Change the RTF options to add frames to the file RtfDocumentOptions rtfOptions = docWriter.GetOptions(DocumentFormat.Rtf) as RtfDocumentOptions; rtfOptions.Framed = true; docWriter.SetOptions(DocumentFormat.Rtf, rtfOptions); // Create a new RTF document Console.WriteLine("Creating new RTF document: {0}", outputFileName); docWriter.BeginDocument(outputFileName, DocumentFormat.Rtf); // Use the Windows API to load the EMF IntPtr emfHandle = GetEnhMetaFile(emfFileName); // Add the page DocumentPage page = DocumentPage.Empty; page.EmfHandle = emfHandle; page.Image = null; Console.WriteLine("Adding EMF page from: {0}", emfFileName); docWriter.AddPage(page); // Use the Windows API to delete the EMF DeleteEnhMetaFile(emfHandle); // Finally finish writing the RTF file on disk docWriter.EndDocument(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2