LEADTOOLS Forms (Leadtools.Forms.DocumentWriters assembly)
LEAD Technologies, Inc

SaveOptions(Stream) Method

Example 





A standard .NET System.IO.Stream to save the options to.
Saves the document options to an XML stream. .NET support
Syntax
public void SaveOptions( 
   Stream stream
)
'Declaration
 
Public Overloads Sub SaveOptions( _
   ByVal stream As Stream _
) 
'Usage
 
Dim instance As DocumentWriter
Dim stream As Stream
 
instance.SaveOptions(stream)
public void SaveOptions( 
   Stream stream
)
 function Leadtools.Forms.DocumentWriters.DocumentWriter.SaveOptions(Stream)( 
   stream 
)
public:
void SaveOptions( 
   Stream^ stream
) 

Parameters

stream
A standard .NET System.IO.Stream to save the options to.
Remarks

To load the options saved into a .NET stream the SaveOptions(Stream) method, use LoadOptions(Stream).

To load and save the options to an XML file on disk instead of a stream, use LoadOptions(string) and SaveOptions(string).

Saving the options to an XML file allows the options to be the required way once and then re-used in multiple sessions (or multiple DocumentWriter instances). Each document format supported by the LEADTOOLS Document Writer contain extra functionality and options that can be accessed with the GetOptions and SetOptions methods. For more information, refer to DocumentOptions.

The following options are saved to the XML:

Example
 
Private Sub DocumentOptionsStreamExample()
   ' Use a memory stream to save the options to
   Dim ms As New MemoryStream()
   ' Create a new instance of the LEADTOOLS Document Writer
   Dim docWriter1 As New DocumentWriter()

   ' Show the default PDF and HTML options before
   ShowMyOptions("Default options for docWriter1", docWriter1)

   ' Change the PDF options and HTML options
   Dim pdfOptions As PdfDocumentOptions = DirectCast(docWriter1.GetOptions(DocumentFormat.Pdf), PdfDocumentOptions)
   pdfOptions.DocumentType = PdfDocumentType.PdfA
   pdfOptions.ImageOverText = True
   docWriter1.SetOptions(DocumentFormat.Pdf, pdfOptions)

   Dim htmlOptions As HtmlDocumentOptions = DirectCast(docWriter1.GetOptions(DocumentFormat.Html), HtmlDocumentOptions)
   htmlOptions.DocumentType = HtmlDocumentType.IENetscape
   htmlOptions.UseBackgroundColor = True
   htmlOptions.BackgroundColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue)
   docWriter1.SetOptions(DocumentFormat.Html, htmlOptions)

   ' Show the options again
   ShowMyOptions("New options for docWriter1", docWriter1)

   ' Save these options to the stream
   docWriter1.SaveOptions(ms)
   ' Reset the stream back to its original position
   ms.Position = 0

   ' Create a new DocumentWriter object
   Dim docWriter2 As New DocumentWriter()

   ' Show its options, should be the defaults
   ShowMyOptions("Default options for docWriter2", docWriter2)

   ' Load the options from the memory to this object
   docWriter2.LoadOptions(ms)

   ' Show the options now, should be the saved ones
   ShowMyOptions("Options for docWriter2 after loading from the XML file", docWriter2)
End Sub

Private Sub ShowMyOptions(ByVal message As String, ByVal docWriter As DocumentWriter)
   Console.WriteLine(message)

   Dim pdfOptions As PdfDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Pdf), PdfDocumentOptions)
   Console.WriteLine("  PDF options: ")
   Console.WriteLine("    DocumentType:  " + pdfOptions.DocumentType.ToString())
   Console.WriteLine("    FontEmbedMode: " + pdfOptions.FontEmbedMode.ToString())
   Console.WriteLine("    ImageOverText: " + pdfOptions.ImageOverText.ToString())

   Dim htmlOptions As HtmlDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Html), HtmlDocumentOptions)
   Console.WriteLine("  HTML options: ")
   Console.WriteLine("    DocumentType:       " + htmlOptions.DocumentType.ToString())
   Console.WriteLine("    FontEmbedMode:      " + htmlOptions.FontEmbedMode.ToString())
   Console.WriteLine("    UseBackgroundColor: " + htmlOptions.UseBackgroundColor.ToString())
   Console.WriteLine("    BackgroundColor:    " + htmlOptions.BackgroundColor.ToString())
   Console.WriteLine("-------------------------")
End Sub
private void DocumentOptionsStreamExample()
{
   // Use a memory stream to save the options to
   MemoryStream ms = new MemoryStream();
   // Create a new instance of the LEADTOOLS Document Writer
   DocumentWriter docWriter1 = new DocumentWriter();

   // Show the default PDF and HTML options before
   ShowMyOptions("Default options for docWriter1", docWriter1);

   // Change the PDF options and HTML options
   PdfDocumentOptions pdfOptions = docWriter1.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
   pdfOptions.DocumentType = PdfDocumentType.PdfA;
   pdfOptions.ImageOverText = true;
   docWriter1.SetOptions(DocumentFormat.Pdf, pdfOptions);

   HtmlDocumentOptions htmlOptions = docWriter1.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions;
   htmlOptions.DocumentType = HtmlDocumentType.IENetscape;
   htmlOptions.UseBackgroundColor = true;
   htmlOptions.BackgroundColor = RasterColor.FromKnownColor(RasterKnownColor.LightBlue);
   docWriter1.SetOptions(DocumentFormat.Html, htmlOptions);

   // Show the options again
   ShowMyOptions("New options for docWriter1", docWriter1);

   // Save these options to the stream
   docWriter1.SaveOptions(ms);
   // Reset the stream back to its original position
   ms.Position = 0;

   // Create a new DocumentWriter object
   DocumentWriter docWriter2 = new DocumentWriter();

   // Show its options, should be the defaults
   ShowMyOptions("Default options for docWriter2", docWriter2);

   // Load the options from the memory to this object
   docWriter2.LoadOptions(ms);

   // Show the options now, should be the saved ones
   ShowMyOptions("Options for docWriter2 after loading from the XML file", docWriter2);
}

private void ShowMyOptions(string message, DocumentWriter docWriter)
{
   Console.WriteLine(message);

   PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
   Console.WriteLine("  PDF options: ");
   Console.WriteLine("    DocumentType:  " + pdfOptions.DocumentType);
   Console.WriteLine("    FontEmbedMode: " + pdfOptions.FontEmbedMode);
   Console.WriteLine("    ImageOverText: " + pdfOptions.ImageOverText);

   HtmlDocumentOptions htmlOptions = docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions;
   Console.WriteLine("  HTML options: ");
   Console.WriteLine("    DocumentType:       " + htmlOptions.DocumentType);
   Console.WriteLine("    FontEmbedMode:      " + htmlOptions.FontEmbedMode);
   Console.WriteLine("    UseBackgroundColor: " + htmlOptions.UseBackgroundColor);
   Console.WriteLine("    BackgroundColor:    " + htmlOptions.BackgroundColor);
   Console.WriteLine("-------------------------");
}
Requirements

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

See Also

Reference

DocumentWriter Class
DocumentWriter Members
Overload List
DocumentPage Structure
DocumentFormat Enumeration
Programming with LEADTOOLS Document Writers
Files to be Included with Your Application
Unlocking Special LEAD Features

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Forms.DocumentWriters requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features