-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetFontFamily pattern for every document created #45
Comments
It's not exposed now, but I would suggest doing this differently. Just work without setting font family and then once everything is done just loop thru all paragraphs foreach (var paragraph in document.Paragraphs) {
paragraph.SetFontFamily(...).SetFontSize(10)
} You will fix this in 3 lines. I'll keep this open, as it should be possible to define default font/style. |
Thanks, I thought I had a generic method, but so too solves my problem. |
I will add native way to do it in next release: |
PR was merged public static void Example_BasicWordWithDefaultStyleChange(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with different default style");
string filePath = System.IO.Path.Combine(folderPath, "BasicWordWithDefaultStyleChange.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
document.Settings.FontSize = 30;
document.Settings.FontFamily = "Calibri Light";
document.Settings.Language = "pl-PL";
var paragraph1 = document.AddParagraph("To jest po polsku");
var paragraph2 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
paragraph2.FontSize = 15;
paragraph2.FontFamily = "Courier New";
document.Save(openWord);
}
} Should be available in next version |
Would you have to set a default FontFamily for every document, without having to add to each paragraph you create?
follows the example in the image.
The text was updated successfully, but these errors were encountered: