forked from totravel/minidocx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.cpp
33 lines (25 loc) · 949 Bytes
/
run.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include "minidocx.hpp"
int main()
{
docx::Document doc;
auto p = doc.AppendParagraph();
auto r = p.AppendRun(u8"你好,World!", 16, "Times New Roman", "Microsoft YaHei UI");
r.SetCharacterSpacing(docx::Pt2Twip(2));
r.SetFontStyle(docx::Run::Bold | docx::Run::Underline);
r.SetFontStyle(docx::Run::Bold | docx::Run::Italic);
auto fontStyle = r.GetFontStyle();
r.SetFontStyle(fontStyle | docx::Run::Strikethrough);
auto fontSize = r.GetFontSize();
std::cout << "Font Size: " << fontSize << std::endl;
auto characterSpacing = docx::Twip2Pt(r.GetCharacterSpacing());
std::cout << "Character Spacing: " << characterSpacing << std::endl;
std::string fontAscii, fontEastAsia;
r.GetFont(fontAscii, fontEastAsia);
std::cout << "Font Ascii: " << fontAscii << std::endl;
std::cout << "Font East Asia: " << fontEastAsia << std::endl;
doc.Save("run.docx");
return 0;
}