-
-
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
Handling of new line characters #37
Comments
Currntly break is exposed but for Document, and not Paragraph. OfficeIMO/OfficeIMO.Word/WordDocument.PublicMethods.cs Lines 23 to 44 in 7010fd2
|
public static void Example_BasicWordWithBreaks(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with paragraph & breaks");
string filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithParagraphsAndBreaks.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph1 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
var paragraph2 = document.AddParagraph("Adding paragraph2 with some text and pressing SHIFT+ENTER");
paragraph2.AddBreak();
paragraph2.AddText("Continue1");
paragraph2.AddBreak();
paragraph2.AddText("Continue2");
var paragraph3 = document.AddParagraph("Adding paragraph3 with some text and pressing ENTER");
document.Save(openWord);
}
} Would that work? public static void Example_BasicWordWithBreaks(string folderPath, bool openWord) {
Console.WriteLine("[*] Creating standard document with paragraph & breaks");
string filePath = System.IO.Path.Combine(folderPath, "BasicDocumentWithParagraphsAndBreaks.docx");
using (WordDocument document = WordDocument.Create(filePath)) {
var paragraph1 = document.AddParagraph("Adding paragraph1 with some text and pressing ENTER");
var paragraph2 = document.AddParagraph("Adding paragraph2 with some text and pressing SHIFT+ENTER");
paragraph2.AddBreak();
paragraph2.AddText("Continue1");
paragraph2.AddBreak();
paragraph2.AddText("Continue2");
var paragraph3 = document.AddParagraph("Adding paragraph3 with some text and pressing ENTER");
var paragraph4 = document.AddParagraph("Adding paragraph4 with some text and pressing SHIFT+ENTER");
paragraph4.AddBreak();
document.Save(openWord);
}
} Which looks like this |
Will be available in 0.3.0 |
Added a way to use NewLines directly in text: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now if the text contains
NewLine
character, the rendering asText
orParagraph
ignores the newline and renders its as plain text.If we manually add
Paragraph
there is additional BREAK (ENTER) rendered which is not rendered if we press SHIFT+ENTER in Word.Example
This will render the Word Document as below,
What is expected is
Please suggest what is the best way to replace an
ENTER
with aSHIFT+ENTER
The text was updated successfully, but these errors were encountered: