// HelloDocx.cs — SmartScribe.Docx SDK .NET quick-start
// Requires SmartScribeDocx.cs (from bindings/dotnet/) in the same project
// and SmartScribeDocx.dll on the system PATH or in the executable directory.

using System;

class HelloDocx
{
    static void Main(string[] args)
    {
        string path = args.Length > 0 ? args[0] : "sample.docx";
        Console.WriteLine($"SmartScribe.Docx SDK — opening {path}");

        using var doc = SmartScribeDocx.Open(path);

        // Read margins (twips; 1440 twips = 1 inch)
        doc.GetMargins(out int top, out int bottom, out int left, out int right,
                       out int hd, out int fd, out int gutter, out int mirror);
        Console.WriteLine($"Margins: top={top} bottom={bottom} left={left} right={right}");

        // Set 1-inch margins
        doc.SetMargins(1440, 1440, 1440, 1440, 709, 709, 0, 0);

        // Document properties
        doc.SetDocProperty("title",  "My Document");
        doc.SetDocProperty("author", "Dan Shields");

        // Header: page number right-aligned
        byte[] hdr = doc.BuildHfXml(isHeader: true,
                                     template: "Page {PAGE} of {NUMPAGES}",
                                     alignment: "right");
        doc.SetHeaderXml(SmartScribeDocx.HF_DEFAULT, hdr);

        // Footer: author and title centered
        byte[] ftr = doc.BuildHfXml(isHeader: false,
                                     template: "{AUTHOR}  |  {TITLE}",
                                     alignment: "center");
        doc.SetFooterXml(SmartScribeDocx.HF_DEFAULT, ftr);

        doc.SaveAs("output.docx");
        Console.WriteLine("Saved to output.docx");
    }
}
