Closed punitganshani closed 1 year ago
So - the difference between ENTER and SHIFT+ENTER on the XML tells us what the issue is about:
Enter
SHIFT+ENTER
I would probably need to add new method for paragraph AddBreak to allow you to use it. Unless you would be willing to do that
Currntly break is exposed but for Document, and not Paragraph.
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:
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