Comments (6)
Right, but I treat 1 run = 1 WordParagraph in OfficeIMO. And then 1 Paragraph can have multiple runs and be attached to multiple WordParagraphs. So in the end you want a class named like WordParagraphStyle which would have Public property _RunStyle which would allow deep diving if someone doesn't like the "easy" get/set and there would be bunch of defined properties that control things? Or do I misunderstand? Feel free to ignore me tho.
from officeimo.
@PrzemyslawKlys maybe you have a vision where/within what it is better to add it?
from officeimo.
I am not sure I understand the question. From what I see I use it exactly 2 times as part of WordHyperLink.
I assume you want to add ability to create custom style and RunStyle is part of making sure that happens.
When I look at Word there are multiple, but limited styles built in + the styles that are part of TOC, again quite limited. I've defined only styles as part of TOC I believe.
My idea would be to recreate all the styles that come built-in in Word with their respective name and so on so the user can find out by checking what style it is, but if it doesn't match defined styles it would refer to custom style. ANd custom style would be separate class with it's own definitions? This class would mainly limit inputs to what the GUI proposes?
I don't have super experience with this so I'm open to suggestions.
From what I see in Aspose:
Document doc = new Document();
// Create a paragraph style and specify some formatting for it
Style style = doc.Styles.Add(StyleType.Paragraph, "MyStyle1");
style.Font.Size = 24;
style.Font.Name = "Verdana";
style.ParagraphFormat.SpaceAfter = 12;
- https://learn.microsoft.com/en-us/office/open-xml/how-to-create-and-add-a-character-style-to-a-word-processing-document
- https://learn.microsoft.com/en-us/office/open-xml/how-to-create-and-add-a-paragraph-style-to-a-word-processing-document
- Devexpress - https://docs.devexpress.com/OfficeFileAPI/400460/word-processing-document-api/text-formatting
//Open the document for editing
document.BeginUpdate();
//Create a new paragraph style instance
//and specify the required properties
ParagraphStyle chapterStyle = document.ParagraphStyles.CreateNew();
chapterStyle.Name = "MyTitleStyle";
chapterStyle.ForeColor = Color.SteelBlue;
chapterStyle.FontSize = 16;
chapterStyle.FontName = "Segoe UI Semilight";
chapterStyle.Alignment = ParagraphAlignment.Left;
chapterStyle.SpacingBefore = Units.InchesToDocumentsF(0.2f);
chapterStyle.SpacingAfter = Units.InchesToDocumentsF(0.2f);
chapterStyle.OutlineLevel = 2;
//Add the object to the document collection
document.ParagraphStyles.Add(chapterStyle);
//Finalize the editing
document.EndUpdate();
//Apply the created style to every chapter in the document
for (int i = 0; i < document.Paragraphs.Count; i++)
{
string var = document.GetText(document.Paragraphs[i].Range);
if (var.Contains("Chapter "))
{
document.Paragraphs[i].Style = chapterStyle;
}
}
return;
🤷♂️
from officeimo.
Here's one from Syncfusion
//Creates a Word document
using (WordDocument document = new WordDocument())
{
//This method adds a section and a paragraph in the document
document.EnsureMinimal();
//Adds a new paragraph style named "ParagraphStyle"
WParagraphStyle paraStyle = document.AddParagraphStyle("ParagraphStyle") as WParagraphStyle;
//Sets the formatting of the style
paraStyle.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
//Adds a new character style named "CharacterStyle"
IWCharacterStyle charStyle = document.AddCharacterStyle("CharacterStyle");
//Sets the formatting of the style
charStyle.CharacterFormat.Bold = true;
charStyle.CharacterFormat.Italic = true;
//Link both paragraph and character style
paraStyle.LinkedStyleName = "CharacterStyle";
//Appends the contents into the paragraph
document.LastParagraph.AppendText("AdventureWorks Cycles");
//Applies the style to paragraph
document.LastParagraph.ApplyStyle("ParagraphStyle");
//Appends new paragraph in section
document.LastSection.AddParagraph();
//Appends the contents into the paragraph
document.LastParagraph.AppendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.");
//Applies paragraph style to the text range
(document.LastParagraph.ChildEntities[0] as WTextRange).ApplyStyle("ParagraphStyle");
//Saves the document
document.Save("Result.docx", FormatType.Docx);
}
So I guess separate class that you "define" and later on you build it up and apply to paragraphs. Hope that is what you are asking
from officeimo.
This is necessary to support the inline style. For example, as you rightly noted Hyperlink. Or another example — inlined code
from officeimo.
So I guess separate class that you "define" and later on you build it up and apply to paragraphs. Hope that is what you are asking
Not exactly, it's not for paragraphs, it's for the Run. Ran part of a paragraph and it can have its own style
from officeimo.
Related Issues (20)
- Document properties are not set when saving to Stream HOT 3
- mathematical formulas HOT 1
- Blank protection password not accepted when trying to unprotect generated word document HOT 4
- Insert image with fixed position HOT 6
- Add 3D Charts HOT 1
- Color applied to first paragraph in header/footer ignored HOT 7
- How to reset page numbers in a new section HOT 1
- Make the FindAndReplace(List<WordParagraph> ... ) method public HOT 1
- Inserting Tables HOT 1
- Documentation for attribute WordParagraph.underline links to MSDN HOT 5
- [Bug]Do Table Cells support adding images? HOT 7
- [Potential Bug] Paragraph AddText Method sets given text to the current run before adding the paragraph. HOT 4
- Horizontal Merge Weird Behaviour HOT 1
- Place Text at specific location HOT 13
- TextBox.WidthCentimeters only respected if RelativeWidthPercentage set to 0 HOT 1
- What units are "WordDocument.Margins" in? HOT 3
- Questions around TextBox HOT 23
- InvalidProgramException HOT 5
- Open Office Writer can't open document created with OfficeIMO HOT 17
- Add Combo Chart HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officeimo.