Saves the document options to an XML file on disk.
Syntax
Visual Basic (Declaration) | |
---|
Overloads Public Sub SaveOptions( _
ByVal fileName As String _
) |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As DocumentWriter
Dim fileName As String
instance.SaveOptions(fileName)
|
Parameters
- fileName
- The name of XML file to save the options to.
Example
This example will change some of the options in a DocumentWriter object, saves them to disk and then re-load them in a new instance.
Visual Basic | Copy Code |
---|
Private Sub DocumentOptionsDiskExample()
RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here")
RasterSupport.Unlock(RasterSupportType.DocumentWritersPdf, "Replace with your own key here")
Dim xmlFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "DocumentWriterOptions.xml"
Dim docWriter1 As New DocumentWriter()
ShowOptions("Default options for docWriter1", docWriter1)
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 = Color.LightBlue
docWriter1.SetOptions(DocumentFormat.Html, htmlOptions)
ShowOptions("New options for docWriter1", docWriter1)
docWriter1.SaveOptions(xmlFileName)
Dim docWriter2 As New DocumentWriter()
ShowOptions("Default options for docWriter2", docWriter2)
docWriter2.LoadOptions(xmlFileName)
ShowOptions("Options for docWriter2 after loading from the XML file", docWriter2)
End Sub
Private Sub ShowOptions(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 |
C# | Copy Code |
---|
private void DocumentOptionsDiskExample() { // Unlock the support needed for LEADTOOLS Document Writers (with PDF output) RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here"); RasterSupport.Unlock(RasterSupportType.DocumentWritersPdf, "Replace with your own key here"); string xmlFileName = LeadtoolsExamples.Common.ImagesPath.Path + "DocumentWriterOptions.xml"; // Create a new instance of the LEADTOOLS Document Writer DocumentWriter docWriter1 = new DocumentWriter(); // Show the default PDF and HTML options before ShowOptions("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 = Color.LightBlue; docWriter1.SetOptions(DocumentFormat.Html, htmlOptions); // Show the options again ShowOptions("New options for docWriter1", docWriter1); // Save these options to disk docWriter1.SaveOptions(xmlFileName); // Create a new DocumentWriter object DocumentWriter docWriter2 = new DocumentWriter(); // Show its options, should be the defaults ShowOptions("Default options for docWriter2", docWriter2); // Load the options from disk to this object docWriter2.LoadOptions(xmlFileName); // Show the options now, should be the saved ones ShowOptions("Options for docWriter2 after loading from the XML file", docWriter2); } private void ShowOptions(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("-------------------------"); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also