### Document Signing Example using Fluent API Source: https://reference.wordize.com/net/wordize.digitalsignatures/signercontext Demonstrates how to sign a document using the Fluent API of the Wordize library. It shows the setup of CertificateHolder and SignerContext, including specifying XMLDSig level, and then executing the signing process. ```csharp CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw"); SignerContext context = new SignerContext(); context.CertificateHolder = certHolder; context.SignOptions = new SignOptions() { XmlDsigLevel = XmlDsigLevel.XAdEsEpes }; Signer.Create(context) .From(MyDir + "Simple.docx") .To(ArtifactsDir + "Signed.docx") .Execute(); ``` -------------------------------- ### Demonstrate Getting and Printing Available Fonts - C# Source: https://reference.wordize.com/net/wordize.fonts/fontsettings/getfontssources This example demonstrates how to obtain the list of font sources using GetFontsSources and then iterate through each source to print the names of the available fonts. It utilizes FontSourceBase and PhysicalFontInfo classes. ```csharp private static void PrintAvaialbleFonts(FontSettings fontSettings) { FontSourceBase[] fontSources = fontSettings.GetFontsSources(); foreach (FontSourceBase fontSource in fontSources) { Console.WriteLine("----------{0}----------", fontSource.Type); foreach (PhysicalFontInfo pfi in fontSource.GetAvailableFonts()) { Console.WriteLine(pfi.FullFontName); } } } ``` -------------------------------- ### Grammar Checking Example Source: https://reference.wordize.com/net/wordize.ai/grammarchecker Example demonstrating how to create a custom OpenAI model and perform grammar checking on a document. ```APIDOC ## Grammar Checking Example Shows how to create custom OpenAiModel and perform grammar checking. ### Request Example ```csharp string apiUrl = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_URL", EnvironmentVariableTarget.User); string apiName = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_NAME", EnvironmentVariableTarget.User); string apiKey = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(apiUrl, apiName, apiKey); CheckGrammarOptions options = new CheckGrammarOptions() { MakeRevisions = true }; GrammarChecker.CheckGrammar(MyDir + "SimpleAI.docx", ArtifactsDir + "CheckGrammar.docx", model, options); ``` ``` -------------------------------- ### Load Linux Settings Example - C# Source: https://reference.wordize.com/net/wordize.fonts/tablesubstitutionrule/loadlinuxsettings This example demonstrates how to call the LoadLinuxSettings method. It requires an instance of FontSettings, and then accesses the TableSubstitution property to invoke LoadLinuxSettings. This action loads the specific table substitution settings applicable to Linux. ```csharp FontSettings fontSettings = new FontSettings(); fontSettings.SubstitutionSettings.TableSubstitution.LoadLinuxSettings(); ``` -------------------------------- ### Example: Convert DOCX to PDF using Fluent API - C# Source: https://reference.wordize.com/net/wordize/processor/from This example demonstrates how to use the Processor.From method within a Fluent API chain to convert a DOCX document to PDF. It showcases setting the input file, the output file, and executing the conversion. ```csharp Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "Converter.ConvertToPdf.pdf") .Execute(); ``` -------------------------------- ### Load Android Settings Example - C# Source: https://reference.wordize.com/net/wordize.fonts/tablesubstitutionrule/loadandroidsettings This C# example demonstrates how to use the LoadAndroidSettings method. It involves creating an instance of FontSettings and then calling LoadAndroidSettings on its SubstitutionSettings.TableSubstitution property to apply Android-specific table substitution rules. ```csharp FontSettings fontSettings = new FontSettings(); fontSettings.SubstitutionSettings.TableSubstitution.LoadAndroidSettings(); ``` -------------------------------- ### C# Example: Setting LoadOptions.UseSystemLcid and Converting Document Source: https://reference.wordize.com/net/wordize.loading/loadoptions/usesystemlcid This C# example demonstrates how to instantiate LoadOptions, set the UseSystemLcid property to true, and then use these options during document conversion. It assumes the existence of a Converter class and specifies input and output file paths. ```csharp LoadOptions loadOptions = new LoadOptions(); loadOptions.UseSystemLcid = true; Converter.Create() .From(MyDir + "UseSystemLcid.docx", loadOptions) .To(ArtifactsDir + "LoadOptions.UseSystemLcid.docx") .Execute(); ``` -------------------------------- ### Document Signing with SignOptions.SignTime Example (C#) Source: https://reference.wordize.com/net/wordize.digitalsignatures/signoptions/signtime This C# example demonstrates how to sign a document using the SignOptions class and its SignTime property. It shows the creation of a CertificateHolder, instantiation of SignOptions, setting custom comments and the SignTime to the current date and time, and finally calling the Signer.Sign method. ```csharp CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw"); SignOptions signOptions = new SignOptions(); signOptions.Comments = "Test Signing"; signOptions.SignTime = DateTime.Now; Signer.Sign(MyDir + "Simple.docx", ArtifactsDir + "Signed.docx", certHolder, signOptions); ``` -------------------------------- ### C# Example: Opening Password Encrypted Document with LoadOptions.Password Source: https://reference.wordize.com/net/wordize.loading/loadoptions/password This C# example demonstrates how to use the LoadOptions.Password property to open a password-encrypted document. It initializes LoadOptions, sets the Password property, and then uses the Converter to process the document. This is useful for programmatic access to protected files. ```csharp LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "wordize"; Converter.Create() .From(MyDir + "SimpleEncrypted.docx", loadOptions) .To(ArtifactsDir + "LoadOptions.Password.pdf") .Execute(); ``` -------------------------------- ### MergerContext Usage Example Source: https://reference.wordize.com/net/wordize.merging/mergercontext An example demonstrating how to use the MergerContext class with the fluent API to merge documents. ```APIDOC ## Example: Merging Documents ### Description Shows how to merge several documents using fluent API specifying merge format mode. ### Code ```csharp MergerContext context = new MergerContext(); context.MergeFormatMode = MergeFormatMode.KeepSourceLayout; Merger.Create() .From(MyDir + "Merger.docx") .From(MyDir + "Merger.doc") .From(MyDir + "Merger.rtf") .To(ArtifactsDir + "Merger.KeepSourceLayout.docx") .Execute(); ``` ``` -------------------------------- ### Example: BuildReport with JsonDataSource and SaveFormat.Svg Source: https://reference.wordize.com/net/wordize.reporting/reportbuilder/buildreport This C# example demonstrates how to use the BuildReport method to fill a DOCX template with data from a JSON file and save the output as an SVG image. It utilizes JsonDataSource for data input and specifies 'data' as the data source name within the template. The example ensures proper stream handling using 'using' statements. ```csharp JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json"); using (Stream input = File.OpenRead(MyDir + "ReportingTemplateForeach.docx")) using (Stream output = File.Create(ArtifactsDir + "ReportingForeachJsonDataSource.svg")) { ReportBuilder.BuildReport(input, output, SaveFormat.Svg, new object[] { ds }, new string[] { "data" }); } ``` -------------------------------- ### Enable Exporting Page Setup to HTML - C# Source: https://reference.wordize.com/net/wordize.saving/htmlsaveoptions/exportpagesetup Demonstrates how to enable the export of page margins and page setup information to an HTML file using HtmlSaveOptions in C#. This involves setting the ExportPageMargins and ExportPageSetup properties to true before executing the conversion. ```csharp HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(); htmlSaveOptions.ExportPageMargins = true; htmlSaveOptions.ExportPageSetup = true; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "HtmlSaveOptions.ExportPageMargins.html", htmlSaveOptions) .Execute(); ``` -------------------------------- ### C# Example: Convert EquationXML Shapes to Office Math Source: https://reference.wordize.com/net/wordize.loading/loadoptions/convertshapetoofficemath This C# example demonstrates how to enable the conversion of shapes with EquationXML to Office Math objects using the LoadOptions.ConvertShapeToOfficeMath property. It then uses the Converter class to process a document, applying these options before saving it as a PDF. ```csharp LoadOptions loadOptions = new LoadOptions(); loadOptions.ConvertShapeToOfficeMath = true; Converter.Create() .From(MyDir + "Math shapes.docx", loadOptions) .To(ArtifactsDir + "LoadOptions.ConvertShapeToOfficeMath.pdf") .Execute(); ``` -------------------------------- ### StreamFontSource Implementation Example (C#) Source: https://reference.wordize.com/net/wordize.fonts/streamfontsource An example demonstrating how to implement the StreamFontSource class. This involves creating a derived class and overriding the OpenFontDataStream method to provide font data from a file. ```csharp private class StreamFontSourceIml : StreamFontSource { public StreamFontSourceIml(int priority, string cacheKey) : base(priority, cacheKey) { } public override Stream OpenFontDataStream() { return File.OpenRead(MyDir + @"MyFonts\NoticiaText-Regular.ttf"); } } ``` -------------------------------- ### C# Example: Custom OpenAI Model for Grammar Checking with MakeRevisions Source: https://reference.wordize.com/net/wordize.ai/checkgrammaroptions/makerevisions This C# example demonstrates how to configure a custom OpenAI model and utilize the MakeRevisions property for grammar checking. It retrieves API credentials from environment variables, creates an AiModel instance, sets MakeRevisions to true, and then performs grammar checking on a document. ```csharp string apiUrl = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_URL", EnvironmentVariableTarget.User); string apiName = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_NAME", EnvironmentVariableTarget.User); string apiKey = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(apiUrl, apiName, apiKey); CheckGrammarOptions options = new CheckGrammarOptions() { MakeRevisions = true }; GrammarChecker.CheckGrammar(MyDir + "SimpleAI.docx", ArtifactsDir + "CheckGrammar.docx", model, options); ``` -------------------------------- ### ChmLoadOptions Example: OriginalFileName Source: https://reference.wordize.com/net/wordize.loading/chmloadoptions Demonstrates how to use the OriginalFileName property to correctly resolve ms-its links in CHM files when saving to HTML. ```APIDOC ## Examples Shows how to resolve URLs like `ms-its:myfile.chm::/index.htm`. ```csharp // The document contains URLs like "ms-its:amhelp.chm::....htm", but it has a different name, // so file links don't work after saving it to HTML. // It is required to define the original filename in ChmLoadOptions to avoid this behavior. ChmLoadOptions loadOptions = new ChmLoadOptions() { OriginalFileName = "amhelp.chm" }; MemoryStream chmStream = new MemoryStream(File.ReadAllBytes(MyDir + "Document with ms-its links.chm")); Converter.Create() .From(chmStream, loadOptions) .To(ArtifactsDir + "TestChmLoadOptions.OriginalFileName.html") .Execute(); ``` ``` -------------------------------- ### C# Example: Using ReportBuilderOptions.UpdateFieldsSyntaxAware Source: https://reference.wordize.com/net/wordize.reporting/reportbuilderoptions/updatefieldssyntaxaware Demonstrates how to set the UpdateFieldsSyntaxAware option to true using C# for the Wordize ReportBuilder. This example shows the setup of a JsonDataSource, ReportBuilderContext, and the subsequent execution of report creation, instructing the engine to ignore template syntax and update fields. ```csharp JsonDataSource ds = new JsonDataSource(MyDir + "ReportingData.json"); ReportBuilderContext context = new ReportBuilderContext(); context.DataSources.Add(ds, "data"); context.ReportBuilderOptions.UpdateFieldsSyntaxAware = true; ReportBuilder.Create(context) .From(MyDir + "ReportingTemplateForeach.docx") .To(ArtifactsDir + "ReportBuilderOptions.UpdateFieldsSyntaxAware.docx") .Execute(); ``` -------------------------------- ### Example: Building a report from an object data source with specific save format (C#) Source: https://reference.wordize.com/net/wordize.reporting/reportbuilder/buildreport Illustrates how to generate a report from a list of custom objects ('DummyData') and save it in XPS format. This example creates a list of 'DummyData', populates it, and then calls the BuildReport method specifying 'SaveFormat.Xps' and the data source name 'data'. ```csharp List data = new List(); data.Add(new DummyData() { Name = "James Bond", Position = "Spy" }); data.Add(new DummyData() { Name = "John Doe", Position = "Unknown" }); ReportBuilder.BuildReport(MyDir + "ReportingTemplateForeach.docx", ArtifactsDir + "ReportingForeachObjectDataSource.xps", SaveFormat.Xps, data, "data"); ``` -------------------------------- ### C# Example: Custom Mail Merge Region Tags Source: https://reference.wordize.com/net/wordize.mailmerging/mailmergeoptions/regionendtag Demonstrates how to set custom start and end tags for mail merge regions using MailMergeOptions. This example creates a DataTable, configures MailMergeOptions with custom tags ('RStart', 'REnd'), and then executes the mail merge. ```csharp DataTable dt = new DataTable("Items"); dt.Columns.Add("Item"); dt.Columns.Add("Quantity"); dt.Columns.Add("Price"); dt.Rows.Add("Orange", 5, 10); dt.Rows.Add("Apple", 10, 4); dt.Rows.Add("Pear", 4, 6); MailMergeOptions mailMergeOptions = new MailMergeOptions(); mailMergeOptions.RegionStartTag = "RStart"; mailMergeOptions.RegionEndTag = "REnd"; MailMerger.ExecuteWithRegions(MyDir + "MailMergeTemplateCustomRegionTags.docx", ArtifactsDir + "MailMergeOptions.RegionTag.docx", SaveFormat.Docx, dt, mailMergeOptions); ``` -------------------------------- ### C# - Example Usage of FontFallbackSettings.BuildAutomatic Source: https://reference.wordize.com/net/wordize.fonts/fontfallbacksettings/buildautomatic Demonstrates how to use the FontFallbackSettings.BuildAutomatic method to initialize fallback settings, save them to an XML file, and then load them back. This involves setting a font folder and interacting with FontSettings. ```csharp FontSettings fontSettings = new FontSettings(); fontSettings.SetFontsFolder(MyDir + "MyFonts", true); fontSettings.FallbackSettings.BuildAutomatic(); // Save fallback setting to file fontSettings.FallbackSettings.Save(ArtifactsDir + "FallbackSettings.xml"); // Load fallback setting from file fontSettings.FallbackSettings.Load(ArtifactsDir + "FallbackSettings.xml"); ``` -------------------------------- ### C# Example: Enabling OpenType Features for PDF Export Source: https://reference.wordize.com/net/wordize.layout/layoutoptions/enabletextshaping This C# example demonstrates how to enable OpenType features by setting the EnableTextShaping property to true. It shows the process of creating a ConverterContext, configuring layout options, and then converting a DOCX file to PDF with text shaping enabled. ```csharp ConverterContext context = new ConverterContext(); context.LayoutOptions.EnableTextShaping = true; Converter.Create(context) .From(MyDir + "Simple.docx") .To(ArtifactsDir + "LayoutOptions.EnableTextShaping.pdf") .Execute(); ``` -------------------------------- ### OpenAiModel Document Translation Example Source: https://reference.wordize.com/net/wordize.ai/aimodel Demonstrates how to create an instance of OpenAiModel and use it to translate a document. It requires an API key for the AI model and specifies the input/output file paths and target language. The primary dependency is the Wordize library. ```csharp string apiKey = Environment.GetEnvironmentVariable("GPT4OMINI_API_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(AiModelType.Gpt4OMini, apiKey); Translator.Translate(MyDir + "SimpleAI.docx", ArtifactsDir + "Translate.docx", model, Language.Ukrainian); ``` -------------------------------- ### Initialize DigitalSignatureDetails and Sign Document - C# Source: https://reference.wordize.com/net/wordize.saving/digitalsignaturedetails This example demonstrates how to initialize the DigitalSignatureDetails class with a CertificateHolder and SignOptions, and then use these details to sign a document during the saving process using the Converter utility. ```csharp CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw"); SignOptions signOptions = new SignOptions(); signOptions.Comments = "Test Signing"; signOptions.SignTime = DateTime.Now; DocSaveOptions docSaveOptions = new DocSaveOptions(); docSaveOptions.DigitalSignatureDetails = new DigitalSignatureDetails(certHolder, signOptions); Converter.Create() .From(MyDir+"Simple.docx") .To(ArtifactsDir+ "DigitalSignatureDetails.doc", docSaveOptions) .Execute(); ``` -------------------------------- ### Create Splitter Processor in C# Source: https://reference.wordize.com/net/wordize.splitting/splitter Demonstrates the static creation of a Splitter processor using a specified Splitter context. This is the entry point for configuring the splitting process. ```csharp Splitter processor = Splitter.Create(_SplitterContext_); ``` -------------------------------- ### HtmlSaveOptions.ExportPageSetup Property Declaration - C# Source: https://reference.wordize.com/net/wordize.saving/htmlsaveoptions/exportpagesetup The C# code snippet shows the public property declaration for ExportPageSetup within the HtmlSaveOptions class. This property is of type boolean and can be accessed for both getting and setting its value, controlling the export behavior of page setup information. ```csharp public bool ExportPageSetup { get; set; } ``` -------------------------------- ### LoadOptions Class Documentation Source: https://reference.wordize.com/net/wordize.loading/loadoptions Documentation for the LoadOptions class, detailing its constructors, properties, and methods. ```APIDOC ## LoadOptions Class Allows to specify additional options (such as password or base URI) when loading a document. ### Constructors - **LoadOptions()**: Initializes a new instance of this class with default values. - **LoadOptions(string)**: Initializes a new instance of this class with the specified password to load an encrypted document. - **LoadOptions(LoadFormat, string, string)**: Initializes a new instance of this class with properties set to the specified values. ### Properties - **BaseUri** (string) - Gets or sets the string that will be used to resolve relative URIs found in the document into absolute URIs when required. Can be `null` or empty string. Default is `null`. - **ConvertMetafilesToPng** (bool) - Gets or sets whether to convert metafile (Wmf or Emf) images to Png image format. Default is `false`. - **ConvertShapeToOfficeMath** (bool) - Gets or sets whether to convert shapes with EquationXML to Office Math objects. Default is `false`. - **Encoding** (Encoding) - Gets or sets the encoding that will be used to load an HTML, TXT, or CHM document if the encoding is not specified inside the document. Can be `null`. Default is `null`. - **FontSettings** (FontSettings) - Allows to specify document font settings. - **IgnoreOleData** (bool) - Specifies whether to ignore the OLE data. - **LanguagePreferences** (LanguagePreferences) - Gets language preferences that will be used when document is loading. - **LoadFormat** (LoadFormat) - Specifies the format of the document to be loaded. Default is Auto. - **MswVersion** (MsWordVersion) - Allows to specify that the document loading process should match a specific MS Word version. Default value is Word2019. - **Password** (string) - Gets or sets the password for opening an encrypted document. Can be `null` or empty string. Default is `null`. - **PreserveIncludePictureField** (bool) - Gets or sets whether to preserve the INCLUDEPICTURE field when reading Microsoft Word formats. The default value is `false`. - **RecoveryMode** (LoadErrorRecovery) - Defines how the document should be handled if errors occur during loading. Use this property to specify whether the system should attempt to recover the document or follow another defined behavior. The default value is TryRecover. - **TempFolder** (string) - Allows to use temporary files when reading document. By default this property is `null` and no temporary files are used. - **UpdateDirtyFields** (bool) - Specifies whether to update the fields with the `dirty` attribute. Default is `false`. - **UseSystemLcid** (bool) - Gets or sets whether to use LCID value obtained from Windows registry to determine page setup default margins. - **WarningCallback** (LoadWarningCallback) - Called during a load operation, when an issue is detected that might result in data or formatting fidelity loss. ### Methods - **Equals(object)**: Determines whether the specified object is equal in value to the current object. ### Example Shows how to convert password encrypted document. ```csharp LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "wordize"; Converter.Create() .From(MyDir + "SimpleEncrypted.docx", loadOptions) .To(ArtifactsDir + "LoadOptions.Password.pdf") .Execute(); ``` ### See Also - namespace Wordize.Loading - assembly Wordize ``` -------------------------------- ### Initialize LoadOptions with Format, Password, and Base URI Source: https://reference.wordize.com/net/wordize.loading/loadoptions/loadoptions This constructor initializes a LoadOptions instance with a specified load format, password for encrypted documents, and a base URI for resolving relative paths. The password and base URI can be null or empty strings. ```csharp public LoadOptions(LoadFormat loadFormat, string password, string baseUri) ``` -------------------------------- ### C# MailMergeOptions RegionStartTag Property Source: https://reference.wordize.com/net/wordize.mailmerging/mailmergeoptions/regionstarttag This code defines the public string property 'RegionStartTag' within the MailMergeOptions class, allowing it to get or set a mail merge region start tag. It is a standard C# property with a getter and setter. ```csharp public string RegionStartTag { get; set; } ``` -------------------------------- ### C# Example: Convert WMF/EMF to PNG on Document Load Source: https://reference.wordize.com/net/wordize.loading/loadoptions/convertmetafilestopng This C# example demonstrates how to enable the conversion of WMF/EMF metafile images to PNG format during document loading using the LoadOptions class. It sets the ConvertMetafilesToPng property to true and then uses the Converter API to process a document, saving the result to a new file. ```csharp LoadOptions loadOptions = new LoadOptions(); loadOptions.ConvertMetafilesToPng = true; Converter.Create() .From(MyDir+"SimpleEmf.docx", loadOptions) .To(ArtifactsDir + "LoadOptions.ConvertMetafilesToPng.docx") .Execute(); ``` -------------------------------- ### Initialize and Use XmlDataLoadOptions with LINQ Reporting Engine Source: https://reference.wordize.com/net/wordize.reporting/xmldataloadoptions This example demonstrates how to initialize XmlDataLoadOptions, set the AlwaysGenerateRootObject property, and use it with XmlDataSource for filling a template from an XML file using the LINQ Reporting Engine. It shows the setup for loading XML data and building a report. ```csharp XmlDataLoadOptions xmlLoadOptions = new XmlDataLoadOptions(); xmlLoadOptions.AlwaysGenerateRootObject = true; XmlDataSource ds = new XmlDataSource(MyDir + "ReportingData.xml", xmlLoadOptions); using (Stream input = File.OpenRead(MyDir + "ReportingTemplateForeach.docx")) using (Stream output = File.Create(ArtifactsDir + "ReportingForeachXmlDataSource.pdf")) { ReportBuilder.BuildReport(input, output, SaveFormat.Pdf, ds); } ``` -------------------------------- ### Define Watermarker Creation Method Signature Source: https://reference.wordize.com/net/wordize.watermarking/watermarker/create Defines the static Create method for the Watermarker class, which accepts a WatermarkerContext to initialize the processor. This is the entry point for creating a Watermarker instance. ```csharp public static Watermarker Create(WatermarkerContext context) ``` -------------------------------- ### Set PDF Digital Signature Timestamp Server UserName Source: https://reference.wordize.com/net/wordize.saving/pdfdigitalsignaturetimestampsettings/username This C# code snippet demonstrates how to set the username for a timestamp server when configuring digital signature details for PDF save options. It shows the property declaration and its usage within a larger example of PDF digital signature setup. ```csharp public string UserName { get; set; } ``` ```csharp CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw"); PdfDigitalSignatureDetails signatureDetails = new PdfDigitalSignatureDetails(certHolder, "Test", "Kharkov", DateTime.Now); signatureDetails.HashAlgorithm = PdfDigitalSignatureHashAlgorithm.Sha512; signatureDetails.TimestampSettings = new PdfDigitalSignatureTimestampSettings("https://freetsa.org/tsr", "Wordize", "1234", TimeSpan.FromSeconds(100)); // Check Timestamp details. Assert.That(signatureDetails.TimestampSettings.Timeout.TotalSeconds, Is.EqualTo(100.0d)); Assert.That(signatureDetails.TimestampSettings.ServerUrl, Is.EqualTo("https://freetsa.org/tsr")); Assert.That(signatureDetails.TimestampSettings.UserName, Is.EqualTo("Wordize")); Assert.That(signatureDetails.TimestampSettings.Password, Is.EqualTo("1234")); PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); pdfSaveOptions.DigitalSignatureDetails = signatureDetails; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "PdfSaveOptions.DigitalSignatureDetails.pdf", pdfSaveOptions) .Execute(); ``` -------------------------------- ### C# Import Underline Formatting Example Source: https://reference.wordize.com/net/wordize.loading/markdownloadoptions Demonstrates how to set the ImportUnderlineFormatting property to true on a MarkdownLoadOptions object to recognize sequences of two plus characters '++' as underline text formatting during document conversion. It shows initialization of MarkdownLoadOptions and its use with the Converter. ```csharp MarkdownLoadOptions mdLoadOptions = new MarkdownLoadOptions(); mdLoadOptions.ImportUnderlineFormatting = true; Converter.Create() .From(MyDir + "Simple.md", mdLoadOptions) .To(ArtifactsDir + "MarkdownLoadOptions.ImportUnderlineFormatting.docx") .Execute(); ``` -------------------------------- ### C# Example: Disable Revision Bars Source: https://reference.wordize.com/net/wordize.layout/revisionoptions/showrevisionbars This C# example demonstrates how to disable the display of revision bars during document conversion. It involves creating a ConverterContext, setting the ShowRevisionBars property to false within the LayoutOptions, and then performing the conversion. The example utilizes the Converter class and assumes the existence of MyDir and ArtifactsDir variables for file paths. ```csharp ConverterContext context = new ConverterContext(); context.LayoutOptions.RevisionOptions.ShowRevisionBars = false; Converter.Create(context) .From(MyDir + "Simple.docx") .To(ArtifactsDir + "RevisionOptions.ShowRevisionBars.pdf") .Execute(); ``` -------------------------------- ### Initialize DigitalSignatureDetails Constructor (C#) Source: https://reference.wordize.com/net/wordize.saving/digitalsignaturedetails/digitalsignaturedetails Initializes a new instance of the DigitalSignatureDetails class using a provided CertificateHolder and SignOptions. The CertificateHolder contains the certificate, and SignOptions specify how the document should be signed. ```csharp public DigitalSignatureDetails(CertificateHolder certificateHolder, SignOptions signOptions) ``` -------------------------------- ### C# Example: Preserving Empty Lines in Markdown Conversion Source: https://reference.wordize.com/net/wordize.loading/markdownloadoptions/preserveemptylines This C# example demonstrates how to use the PreserveEmptyLines property to load a Markdown document while keeping empty lines. It initializes MarkdownLoadOptions, sets PreserveEmptyLines to true, and then uses the Converter to convert a Markdown file to DOCX format. This requires the Wordize library and assumes the existence of 'MyDir', 'Simple.md', 'ArtifactsDir', and 'MarkdownLoadOptions.PreserveEmptyLines.docx'. ```csharp MarkdownLoadOptions mdLoadOptions = new MarkdownLoadOptions(); mdLoadOptions.PreserveEmptyLines = true; Converter.Create() .From(MyDir + "Simple.md", mdLoadOptions) .To(ArtifactsDir + "MarkdownLoadOptions.PreserveEmptyLines.docx") .Execute(); ``` -------------------------------- ### Configure Wordize Licensing Source: https://reference.wordize.com/net/wordize/settings Demonstrates how to license the Wordize component using explicit file paths for various modules. This involves calling the static SetLicense method with the path to the license file. ```csharp Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Core_for_.NET.lic")); // Formats Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Rendering_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_OpenOffice_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Web_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_eBook_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_PDF_Load_for_.NET.lic")); // Features Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Comparison_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Signature_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Mail_Merge_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Merge_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Replacement_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Splitter_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_Watermark_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_LINQ_Reporting_Engine_for_.NET.lic")); Wordize.Settings.SetLicense(Path.Combine(LicenseDir, @"Wordize\Wordize_AI_for_.NET.lic")); ``` -------------------------------- ### XmlDataSource Usage Example Source: https://reference.wordize.com/net/wordize.reporting/xmldatasource An example demonstrating how to initialize an XmlDataSource with custom load options from an XML file and use it with the ReportBuilder to generate a PDF report. ```APIDOC ## XmlDataSource Example Shows how to fill a template from a XML file using LINQ Reporting Engine and save the result to stream. ### Request Example ```csharp XmlDataLoadOptions xmlLoadOptions = new XmlDataLoadOptions(); xmlLoadOptions.AlwaysGenerateRootObject = true; XmlDataSource ds = new XmlDataSource(MyDir + "ReportingData.xml", xmlLoadOptions); using (Stream input = File.OpenRead(MyDir + "ReportingTemplateForeach.docx")) using (Stream output = File.Create(ArtifactsDir + "ReportingForeachXmlDataSource.pdf")) { ReportBuilder.BuildReport(input, output, SaveFormat.Pdf, ds); } ``` ### Response Example (This example does not have a direct response body as it's a file generation operation. The output is a generated PDF file.) ``` -------------------------------- ### C# Example: Using JsonSimpleValueParseMode.Strict Source: https://reference.wordize.com/net/wordize.reporting/jsonsimplevalueparsemode Demonstrates how to set the JsonSimpleValueParseMode to Strict when loading JSON data. This example shows how numbers with leading zeros are preserved as strings in Strict mode. ```csharp string templateString = "Number: <<[Number]>>"; string jsonString = "{ Number : \"0000123\" }"; JsonDataLoadOptions jsonLoadOptions = new JsonDataLoadOptions(); // In Strict simple value parse mode value in { Number : "0000123" } JSON // is considered as a string and leading zeros are preserve. jsonLoadOptions.SimpleValueParseMode = JsonSimpleValueParseMode.Strict; JsonDataSource ds = new JsonDataSource(new MemoryStream(Encoding.UTF8.GetBytes(jsonString)), jsonLoadOptions); ReportBuilderContext context = new ReportBuilderContext(); context.DataSources.Add(ds, ""); ReportBuilder.Create(context) .From(new MemoryStream(Encoding.UTF8.GetBytes(templateString))) .To(ArtifactsDir + "JsonDataLoadOptions.SimpleValueParseMode.docx") .Execute(); ``` -------------------------------- ### Create AnthropicAiModel with AiModelType and ApiKey Source: https://reference.wordize.com/net/wordize.ai/anthropicaimodel/create Creates an `AnthropicAiModel` instance using a predefined `AiModelType` (such as Claude35Sonnet, Claude35Haiku, Claude3Opus, Claude3Sonnet, or Claude3Haiku) and an API key. This is the primary method for initializing supported Anthropic models. ```csharp public static AnthropicAiModel Create(AiModelType modelType, string apiKey) ``` -------------------------------- ### C# - Get and Set CertificateHolder Source: https://reference.wordize.com/net/wordize.digitalsignatures/signercontext/certificateholder This C# code demonstrates how to get and set the CertificateHolder property of a SignerContext object. The CertificateHolder object is crucial for digital signing operations. ```csharp public CertificateHolder CertificateHolder { get; set; } ``` -------------------------------- ### C# Example: Configure Measurement Units in Revisions Source: https://reference.wordize.com/net/wordize.layout/measurementunits Demonstrates how to set the MeasurementUnit for revisions during document conversion using Wordize. This example configures the converter to use Points for measurements in revision balloons. ```csharp ConverterContext context = new ConverterContext(); context.LayoutOptions.RevisionOptions.ShowInBalloons = ShowInBalloons.Format; context.LayoutOptions.RevisionOptions.MeasurementUnit = MeasurementUnits.Points; Converter.Create(context) .From(MyDir + "Simple.docx") .To(ArtifactsDir + "RevisionOptions.MeasurementUnits.pdf") .Execute(); ``` -------------------------------- ### Create Translator Instance Source: https://reference.wordize.com/net/wordize.ai/translator/create Demonstrates how to create a new instance of the Translator processor using the Create method. It takes a TranslatorContext object as input. ```csharp public static Translator Create(TranslatorContext context) ``` -------------------------------- ### Create OpenAiModel with Model Type and API Key Source: https://reference.wordize.com/net/wordize.ai/openaimodel/create This method creates an OpenAiModel instance using a specified AiModelType and an API key. It supports models like Gpt4O, Gpt4OMini, Gpt4Turbo, and Gpt35Turbo. This is useful for standard OpenAI model integrations. ```csharp public static OpenAiModel Create(AiModelType modelType, string apiKey) ``` ```csharp string apiKey = Environment.GetEnvironmentVariable("GPT4OMINI_API_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(AiModelType.Gpt4OMini, apiKey); Translator.Translate(MyDir + "SimpleAI.docx", ArtifactsDir + "Translate.docx", model, Language.Ukrainian); ``` -------------------------------- ### Create Comparer Processor with Context (C#) Source: https://reference.wordize.com/net/wordize.comparing/comparer/create This method creates a comparer processor using a provided ComparerContext object, allowing for custom comparison settings. The example demonstrates setting author, date, and ignoring formatting during comparison. ```csharp ComparerContext context = new ComparerContext(); context.Author = "Wordize"; context.DateTime = DateTime.Now; context.CompareOptions.IgnoreFormatting = true; Comparer.Create(context) .From(MyDir + "CompareV1.docx") .From(MyDir + "CompareV2.docx") .To(ArtifactsDir + "CompareFluentAPI.docx") .Execute(); ``` -------------------------------- ### Get or Set XlsxSaveOptions SectionMode Source: https://reference.wordize.com/net/wordize.saving/xlsxsaveoptions/sectionmode This C# code snippet shows the declaration of the XlsxSaveOptions.SectionMode property. It allows you to get or set the method for handling sections when saving to an XLSX file. The default is MultipleWorksheets. ```csharp public XlsxSectionMode SectionMode { get; set; } ``` -------------------------------- ### Mail Merge with UseWholeParagraphAsRegion Example C# Source: https://reference.wordize.com/net/wordize.mailmerging/mailmergeoptions/usewholeparagraphasregion Demonstrates how to configure MailMergeOptions to control mail merge regions, specifically by setting UseWholeParagraphAsRegion to false. This example uses a DataTable to populate a mail merge template. ```csharp DataTable dt = new DataTable("Items"); dt.Columns.Add("Item"); dt.Columns.Add("Quantity"); dt.Columns.Add("Price"); dt.Rows.Add("Orange", 5, 10); dt.Rows.Add("Apple", 10, 4); dt.Rows.Add("Pear", 4, 6); MailMergeOptions mailMergeOptions = new MailMergeOptions(); mailMergeOptions.MergeDuplicateRegions = true; mailMergeOptions.UseWholeParagraphAsRegion = false; MailMerger.ExecuteWithRegions(MyDir + "MailMergeTemplateRegions.docx", ArtifactsDir + "MailMergeOptions.UseWholeParagraphAsRegion.docx", SaveFormat.Docx, dt, mailMergeOptions); ``` -------------------------------- ### Get or Set RevisionBarsColor Source: https://reference.wordize.com/net/wordize.layout/revisionoptions/revisionbarscolor This C# code snippet demonstrates how to get or set the RevisionBarsColor property. It allows specifying the color for side bars that highlight revised document lines. The default color is Red. ```csharp public RevisionColor RevisionBarsColor { get; set; } ``` -------------------------------- ### Get or Set 3D Effects Rendering Mode - C# Source: https://reference.wordize.com/net/wordize.saving/saveoptions/dml3deffectsrenderingmode This C# code snippet demonstrates how to get or set the Dml3DEffectsRenderingMode property of SaveOptions. It is used to control how 3D effects are rendered when saving a document. ```csharp public Dml3DEffectsRenderingMode Dml3DEffectsRenderingMode { get; set; } ``` ```csharp SaveOptions so = SaveOptions.CreateSaveOptions(SaveFormat.Pdf); so.Dml3DEffectsRenderingMode = Dml3DEffectsRenderingMode.Basic; so.DmlEffectsRenderingMode = DmlEffectsRenderingMode.Simplified; so.DmlRenderingMode = DmlRenderingMode.Fallback; so.ImlRenderingMode = ImlRenderingMode.Fallback; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir+ "SaveOptions.DmlRendering.pdf", so) .Execute(); ``` -------------------------------- ### Create OpenAiModel with Custom URL, Name, and API Key Source: https://reference.wordize.com/net/wordize.ai/openaimodel/create This method allows the creation of an OpenAiModel instance using a custom model URL, a specific name, and an API key. This is ideal for integrating with non-standard or self-hosted AI models. It facilitates document translation through a fluent API. ```csharp public static OpenAiModel Create(string url, string name, string apiKey) ``` ```csharp string apiUrl = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_URL", EnvironmentVariableTarget.User); string apiName = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_NAME", EnvironmentVariableTarget.User); string apiKey = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(apiUrl, apiName, apiKey); TranslatorContext context = new TranslatorContext(model) { Language = Language.Ukrainian }; Translator.Create(context) .From(MyDir + "SimpleAI.docx") .To(ArtifactsDir + "Translate.docx") .Execute(); ``` -------------------------------- ### Create Summarizer Instance (C#) Source: https://reference.wordize.com/net/wordize.ai/summarizer/create Creates a new instance of the Summarizer processor. This method requires a SummarizerContext object which includes the AI model to be used for summarization. The example shows how to initialize a custom OpenAI model and configure summarization options. ```csharp public static Summarizer Create(SummarizerContext context) ``` ```csharp string apiUrl = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_URL", EnvironmentVariableTarget.User); string apiName = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_NAME", EnvironmentVariableTarget.User); string apiKey = Environment.GetEnvironmentVariable("CUSTOM_OPENAI_KEY", EnvironmentVariableTarget.User); AiModel model = OpenAiModel.Create(apiUrl, apiName, apiKey); SummarizerContext context = new SummarizerContext(model); context.SummarizeOptions.SummaryLength = SummaryLength.VeryShort; Summarizer.Create(context) .From(MyDir + "SimpleAI.docx") .To(ArtifactsDir + "Summarize.docx") .Execute(); ``` -------------------------------- ### Get or Set Image Watermark Bytes (C#) Source: https://reference.wordize.com/net/wordize.watermarking/watermarkercontext/imagewatermark This C# code defines the ImageWatermark property, which gets or sets the byte array representing the image to be used as a watermark. It's a core component for image-based watermarking. ```csharp public byte[] ImageWatermark { get; set; } ``` -------------------------------- ### TxtLoadOptions Constructors Source: https://reference.wordize.com/net/wordize.loading/txtloadoptions Details the constructors available for the TxtLoadOptions class. ```APIDOC ## Constructors - **TxtLoadOptions()**: Initializes a new instance of this class with default values. ``` -------------------------------- ### Get or Set UpdateLastPrintedProperty in C# Source: https://reference.wordize.com/net/wordize.saving/saveoptions/updatelastprintedproperty This C# code demonstrates how to get or set the UpdateLastPrintedProperty for SaveOptions. It's used to control whether the 'Last Printed' document property is updated before saving a document. This property is of type bool. ```csharp public bool UpdateLastPrintedProperty { get; set; } ``` ```csharp OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.UpdateCreatedTimeProperty = true; saveOptions.UpdateLastPrintedProperty = true; saveOptions.UpdateLastSavedTimeProperty = true; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "SaveOptions.UpdateProperties.docx", saveOptions) .Execute(); ``` -------------------------------- ### Get or Set EmulateRenderingToSizeOnPageResolution Source: https://reference.wordize.com/net/wordize.saving/metafilerenderingoptions/emulaterenderingtosizeonpageresolution This property gets or sets the resolution in pixels per inch for emulating metafile rendering to the size on a page. It is used only when EmulateRenderingToSizeOnPage is true. The default value is 96, representing a standard display resolution. ```csharp public int EmulateRenderingToSizeOnPageResolution { get; set; } ``` -------------------------------- ### Create GoogleAiModel with AiModelType and API Key Source: https://reference.wordize.com/net/wordize.ai/googleaimodel/create Creates a GoogleAiModel instance using a specified AiModelType and an API key. This method supports models like Gemini15Flash, Gemini15Flash8B, and Gemini15Pro. It requires the AiModelType enumeration and a string for the API key. ```csharp public static GoogleAiModel Create(AiModelType modelType, string apiKey) ``` -------------------------------- ### SignOptions.ProviderId Property (C#) Source: https://reference.wordize.com/net/wordize.digitalsignatures/signoptions/providerid The ProviderId property of the SignOptions class specifies the Class ID (GUID) of the signature provider. The default value is an empty GUID. This property is used to identify the cryptographic service provider for digital signatures. ```csharp public Guid ProviderId { get; set; } ``` -------------------------------- ### C# Example: Setting SaveFormat to OpenXps Source: https://reference.wordize.com/net/wordize.saving/saveoptions/saveformat This C# example demonstrates how to set the SaveFormat property to OpenXps using XpsSaveOptions. It then uses the Converter class to save a document in the specified XPS format. This requires the Wordize.Saving namespace and assembly. ```csharp XpsSaveOptions so = new XpsSaveOptions(); so.SaveFormat = SaveFormat.OpenXps; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "SaveOptions.SaveFormat.xps", so) .Execute(); ``` -------------------------------- ### Create Default Comparer Processor Source: https://reference.wordize.com/net/wordize.comparing/comparer/create This method creates a default comparer processor without any specific configurations. It's a static method within the Comparer class. ```csharp public static Comparer Create() ``` -------------------------------- ### C# Example: Configuring ExportListLabels in HtmlSaveOptions Source: https://reference.wordize.com/net/wordize.saving/htmlsaveoptions/exportlistlabels This C# example demonstrates how to configure the ExportListLabels property for HTML export. It initializes HtmlSaveOptions, sets ExportListLabels to AsInlineText, and then uses a Converter to export a DOCX file to HTML with the specified options. ```csharp HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(); htmlSaveOptions.ExportListLabels = HtmlExportListLabels.AsInlineText; Converter.Create() .From(MyDir + "Simple.docx") .To(ArtifactsDir + "HtmlSaveOptions.ExportListLabels.html", htmlSaveOptions) .Execute(); ``` -------------------------------- ### POST /websites/reference_wordize_net/ConvertToImages Source: https://reference.wordize.com/net/wordize.converting/converter/converttoimages Converts the input file pages to images using a file path. ```APIDOC ## POST /websites/reference_wordize_net/ConvertToImages ### Description Converts the input file pages to images. ### Method POST ### Endpoint /websites/reference_wordize_net/ConvertToImages ### Parameters #### Query Parameters - **inputFile** (String) - Required - The input file name. - **saveOptions** (ImageSaveOptions) - Required - The output’s image save options. ### Request Example { "inputFile": "path/to/your/document.docx", "saveOptions": { "format": "Png" } } ### Response #### Success Response (200) - **streams** (Stream[]) - An array of image streams. The streams should be disposed by the end user. #### Response Example (Binary stream data representing images) ``` -------------------------------- ### C# Example: Merging Documents with MergeFormatMode Source: https://reference.wordize.com/net/wordize.merging/mergeformatmode Demonstrates how to merge multiple documents into a single output file using the Wordize library. This example specifically shows how to utilize the MergeFormatMode.KeepSourceLayout option to preserve the original document layouts. ```csharp string outputFileName = ArtifactsDir + "Merger.Merge.docx"; string[] inputFiles = new string[] { MyDir + "Merger.docx", MyDir + "Merger.doc", MyDir + "Merger.rtf" }; Merger.Merge(outputFileName, inputFiles, SaveFormat.Docx, MergeFormatMode.KeepSourceLayout); ``` -------------------------------- ### HtmlLoadOptions Constructor Overloads (C#) Source: https://reference.wordize.com/net/wordize.loading/htmlloadoptions Demonstrates the different ways to initialize an HtmlLoadOptions object. Constructors allow for default initialization, initialization with a password for encrypted documents, and initialization with specified load format and other properties. ```csharp public HtmlLoadOptions() public HtmlLoadOptions(string password) public HtmlLoadOptions(LoadFormat format, string baseUri, string encoding) ``` -------------------------------- ### Mail Merge with Restarting Lists Example (C#) Source: https://reference.wordize.com/net/wordize.mailmerging/mailmergeoptions/restartlistsateachsection This C# example demonstrates how to use the RestartListsAtEachSection property. It creates a DataTable with sample data, sets the RestartListsAtEachSection option to true, and then executes a mail merge using the MailMerger class. ```csharp DataTable dt = new DataTable(); dt.Columns.Add("FirstName"); dt.Columns.Add("LastName"); dt.Rows.Add("James", "Bond"); dt.Rows.Add("John", "Doe"); MailMergeOptions mailMergeOptions = new MailMergeOptions(); mailMergeOptions.RestartListsAtEachSection = true; MailMerger.Execute(MyDir + "MailMergeTemplate.RestartListsAtEachSection.docx", ArtifactsDir + "MailMerge.RestartListsAtEachSection.docx", SaveFormat.Docx, dt, mailMergeOptions); ``` -------------------------------- ### Initialize LoadOptions with Password Source: https://reference.wordize.com/net/wordize.loading/loadoptions/loadoptions This constructor initializes a new LoadOptions instance, accepting a password to decrypt an encrypted document. The password can be null or an empty string. ```csharp public LoadOptions(string password) ```