#r "nuget: DocumentFormat.OpenXml, 3.2.0"

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;

string outputPath = @"C:\Users\Administrator\Desktop\xxx\宫崎骏介绍.docx";

using var doc = WordprocessingDocument.Create(outputPath, WordprocessingDocumentType.Document);
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(new Body());

var body = mainPart.Document.Body;

// Title
var titlePara = new Paragraph(
    new ParagraphProperties(
        new Justification { Val = JustificationValues.Center },
        new SpacingBetweenLines { After = "400" }
    ),
    new Run(
        new RunProperties(
            new Bold(),
            new FontSize { Val = "36" },
            new FontSizeComplexScript { Val = "36" }
        ),
        new Text("宫崎骏")
    )
);
body.Append(titlePara);

// Content - approximately 200 Chinese characters
string content = "宫崎骏（Hayao Miyazaki），日本著名动画导演、漫画家，1941年出生于东京。他被誉为“日本动画之父”，其作品以精美的画面、深邃的想象力和对人与自然关系的思考而闻名于世。代表作包括《千与千寻》《龙猫》《天空之城》《幽灵公主》《哈尔的移动城堡》等，多次获得日本电影金像奖最佳影片及国际动画奖项。他的动画充满童真与诗意，传递和平、环保与爱的主题，影响了全球无数观众。";

var contentPara = new Paragraph(
    new ParagraphProperties(
        new Justification { Val = JustificationValues.Both },
        new SpacingBetweenLines { After = "200", Line = "360", LineRule = LineSpacingRuleValues.Auto }
    ),
    new Run(
        new RunProperties(
            new FontSize { Val = "24" },
            new FontSizeComplexScript { Val = "24" },
            new RunFonts { Ascii = "SimSun", HighAnsi = "SimSun", EastAsia = "SimSun" }
        ),
        new Text(content)
    )
);
body.Append(contentPara);

// Section properties (A4)
body.Append(new SectionProperties(
    new PageSize { Width = 11906, Height = 16838 },
    new PageMargin { Top = 1440, Right = 1440, Bottom = 1440, Left = 1440 }
));

mainPart.Document.Save();
Console.WriteLine($"Document created: {outputPath}");
Console.WriteLine($"Character count: {content.Length}");
