diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/DateField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/DateField.cs index 368b1aec..c013f7c4 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/DateField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/DateField.cs @@ -6,12 +6,12 @@ namespace MigraDoc.DocumentObjectModel.Fields /// /// DateField is used to reference the date and time the printing starts. /// - public class DateField : DocumentObject + public class DateField : TextBasedDocumentObject { /// /// Initializes a new instance of the DateField class. /// - public DateField() + public DateField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new DateFieldValues(this); } @@ -19,7 +19,7 @@ public DateField() /// /// Initializes a new instance of the DateField class with the specified parent. /// - internal DateField(DocumentObject parent) : base(parent) + internal DateField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new DateFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/InfoField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/InfoField.cs index 939cab56..c7833ad8 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/InfoField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/InfoField.cs @@ -6,12 +6,12 @@ namespace MigraDoc.DocumentObjectModel.Fields /// /// InfoField is used to reference one of the DocumentInfo fields in the document. /// - public class InfoField : DocumentObject + public class InfoField : TextBasedDocumentObject { /// /// Initializes a new instance of the InfoField class. /// - public InfoField() + public InfoField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new InfoFieldValues(this); } @@ -19,7 +19,7 @@ public InfoField() /// /// Initializes a new instance of the InfoField class with the specified parent. /// - internal InfoField(DocumentObject parent) : base(parent) + internal InfoField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new InfoFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumPagesField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumPagesField.cs index cbe58cd5..b0a813ed 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumPagesField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumPagesField.cs @@ -11,7 +11,7 @@ public class NumPagesField : NumericFieldBase /// /// Initializes a new instance of the NumPagesField class. /// - public NumPagesField() + public NumPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new NumPagesFieldValues(this); } @@ -19,7 +19,7 @@ public NumPagesField() /// /// Initializes a new instance of the NumPagesField class with the specified parent. /// - internal NumPagesField(DocumentObject parent) : base(parent) + internal NumPagesField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new NumPagesFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumericFieldBase.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumericFieldBase.cs index ba61bb26..d4b8f20a 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumericFieldBase.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/NumericFieldBase.cs @@ -10,30 +10,30 @@ namespace MigraDoc.DocumentObjectModel.Fields /// NumericFieldBase serves as a base for Numeric fields, which are: /// NumPagesField, PageField, PageRefField, SectionField, SectionPagesField /// - public abstract class NumericFieldBase : DocumentObject + public abstract class NumericFieldBase : TextBasedDocumentObject { /// /// The valid format strings for the supported numeric types. /// protected static readonly string[] ValidFormatStrings = - [ + { "", "ROMAN", "roman", "ALPHABETIC", "alphabetic" - ]; + }; /// /// Initializes a new instance of the NumericFieldBase class. /// - internal NumericFieldBase() + internal NumericFieldBase(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { } /// /// Initializes a new instance of the NumericFieldBase class with the specified parent. /// - internal NumericFieldBase(DocumentObject parent) : base(parent) + internal NumericFieldBase(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageField.cs index 2859532f..e2d46d49 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageField.cs @@ -11,7 +11,7 @@ public class PageField : NumericFieldBase /// /// Initializes a new instance of the PageField class. /// - public PageField() + public PageField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new PageFieldValues(this); } @@ -19,7 +19,7 @@ public PageField() /// /// Initializes a new instance of the PageField class with the specified parent. /// - internal PageField(DocumentObject parent) : base(parent) + internal PageField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new PageFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageRefField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageRefField.cs index b4f80da5..a2ffda45 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageRefField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/PageRefField.cs @@ -11,7 +11,7 @@ public class PageRefField : NumericFieldBase /// /// Initializes a new instance of the PageRefField class. /// - public PageRefField() + public PageRefField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new PageRefFieldValues(this); } @@ -19,7 +19,7 @@ public PageRefField() /// /// Initializes a new instance of the PageRefField class with the necessary bookmark name. /// - public PageRefField(string name) : this() + public PageRefField(string name, TextRenderOption textRenderOption = TextRenderOption.Default) : this(textRenderOption) { Name = name; } @@ -27,7 +27,7 @@ public PageRefField(string name) : this() /// /// Initializes a new instance of the PageRefField class with the specified parent. /// - internal PageRefField(DocumentObject parent) : base(parent) + internal PageRefField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionField.cs index 2b6b410d..09073f63 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionField.cs @@ -11,7 +11,7 @@ public class SectionField : NumericFieldBase /// /// Initializes a new instance of the SectionField class. /// - public SectionField() + public SectionField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new SectionFieldValues(this); } @@ -19,7 +19,7 @@ public SectionField() /// /// Initializes a new instance of the SectionField class with the specified parent. /// - internal SectionField(DocumentObject parent) : base(parent) + internal SectionField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new SectionFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionPagesField.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionPagesField.cs index 3e956db3..bdc2ed69 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionPagesField.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Fields/SectionPagesField.cs @@ -11,7 +11,7 @@ public class SectionPagesField : NumericFieldBase /// /// Initializes a new instance of the SectionPagesField class. /// - public SectionPagesField() + public SectionPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new SectionPagesFieldValues(this); } @@ -19,7 +19,7 @@ public SectionPagesField() /// /// Initializes a new instance of the SectionPagesField class with the specified parent. /// - internal SectionPagesField(DocumentObject parent) : base(parent) + internal SectionPagesField(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new SectionPagesFieldValues(this); } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes.Charts/TextArea.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes.Charts/TextArea.cs index 5c4b0091..aa3a5722 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes.Charts/TextArea.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes.Charts/TextArea.cs @@ -73,9 +73,9 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the text area. /// - public Paragraph AddParagraph(string paragraphText) + public Paragraph AddParagraph(string paragraphText, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddParagraph(paragraphText); + return Elements.AddParagraph(paragraphText, textRenderOption); } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes/TextFrame.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes/TextFrame.cs index dbbf5186..abc6c151 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes/TextFrame.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Shapes/TextFrame.cs @@ -57,8 +57,8 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the text frame. /// - public Paragraph AddParagraph(string paragraphText) - => Elements.AddParagraph(paragraphText); + public Paragraph AddParagraph(string paragraphText, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddParagraph(paragraphText, textRenderOption); /// /// Adds a new chart with the specified type to the text frame. diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Tables/Cell.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Tables/Cell.cs index ce21f9ca..d743685f 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Tables/Cell.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Tables/Cell.cs @@ -98,8 +98,8 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the cell. /// - public Paragraph AddParagraph(string paragraphText) - => Elements.AddParagraph(paragraphText); + public Paragraph AddParagraph(string paragraphText, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddParagraph(paragraphText, textRenderOption); /// /// Adds a new chart with the specified type to the cell. diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Visitors/PdfFlattenVisitor.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Visitors/PdfFlattenVisitor.cs index 2dbe6bb1..8cbb1600 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Visitors/PdfFlattenVisitor.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel.Visitors/PdfFlattenVisitor.cs @@ -106,11 +106,11 @@ internal override void VisitDocumentObjectCollection(DocumentObjectCollection el case '\t': if (currentString.Length > 0) { - elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString())); + elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString(), text.TextRenderOption)); ++insertedObjects; currentString.Clear(); } - elements.InsertObject(idx + insertedObjects, new Text(" ")); + elements.InsertObject(idx + insertedObjects, new Text(" ", text.TextRenderOption)); ++insertedObjects; break; @@ -141,7 +141,7 @@ internal override void VisitDocumentObjectCollection(DocumentObjectCollection el // Only start new Text if minus is not a sign, because numbers like "-5.5" have to be stored in one Text for correct DecimalTab alignment. if (!isSign) { - elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString())); + elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString(), text.TextRenderOption)); ++insertedObjects; currentString.Clear(); } @@ -152,7 +152,7 @@ internal override void VisitDocumentObjectCollection(DocumentObjectCollection el case '\u200C': // zero width non-joiner. if (currentString.Length > 0) { - elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString())); + elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString(), text.TextRenderOption)); ++insertedObjects; currentString.Clear(); } @@ -161,11 +161,11 @@ internal override void VisitDocumentObjectCollection(DocumentObjectCollection el case '\u00AD': // soft hyphen. if (currentString.Length > 0) { - elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString())); + elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString(), text.TextRenderOption)); ++insertedObjects; currentString.Clear(); } - elements.InsertObject(idx + insertedObjects, new Text("\u00AD")); + elements.InsertObject(idx + insertedObjects, new Text("\u00AD", text.TextRenderOption)); ++insertedObjects; //currentString = ""; break; @@ -177,7 +177,7 @@ internal override void VisitDocumentObjectCollection(DocumentObjectCollection el } if (currentString.Length > 0) { - elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString())); + elements.InsertObject(idx + insertedObjects, new Text(currentString.ToString(), text.TextRenderOption)); ++insertedObjects; } elements.RemoveObjectAt(idx + insertedObjects); diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs index 9ff8eb76..60e43454 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Character.cs @@ -7,7 +7,7 @@ namespace MigraDoc.DocumentObjectModel /// Represents a special character in paragraph text. /// // TODO_OLD: Change this class and store symbolName and char in different fields. - public class Character : DocumentObject + public class Character : TextBasedDocumentObject { // ===== \space ===== /// @@ -87,7 +87,7 @@ public class Character : DocumentObject /// /// Initializes a new instance of the Character class. /// - public Character() + public Character(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new CharacterValues(this); } @@ -95,7 +95,7 @@ public Character() /// /// Initializes a new instance of the Character class with the specified parent. /// - internal Character(DocumentObject parent) : base(parent) + internal Character(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new CharacterValues(this); } @@ -103,7 +103,7 @@ internal Character(DocumentObject parent) : base(parent) /// /// Initializes a new instance of the Character class with the specified SymbolName. /// - Character(SymbolName name) : this() + Character(SymbolName name, TextRenderOption textRenderOption = TextRenderOption.Default) : this(textRenderOption) { Values.SymbolName = name; } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentElements.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentElements.cs index 5c9e7a61..b0521ee7 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentElements.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/DocumentElements.cs @@ -53,10 +53,10 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the collection. /// - public Paragraph AddParagraph(string text) + public Paragraph AddParagraph(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { var paragraph = new Paragraph(); - paragraph.AddText(text); + paragraph.AddText(text, textRenderOption); Add(paragraph); return paragraph; } @@ -64,10 +64,10 @@ public Paragraph AddParagraph(string text) /// /// Adds a new paragraph with the specified text and style to the collection. /// - public Paragraph AddParagraph(string text, string style) + public Paragraph AddParagraph(string text, string style, TextRenderOption textRenderOption = TextRenderOption.Default) { var paragraph = new Paragraph(); - paragraph.AddText(text); + paragraph.AddText(text, textRenderOption); paragraph.Style = style; Add(paragraph); return paragraph; diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs index 9cd92099..8f9b46e4 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Footnote.cs @@ -10,12 +10,12 @@ namespace MigraDoc.DocumentObjectModel /// /// Represents a footnote in a paragraph. /// - public class Footnote : DocumentObject, IVisitable + public class Footnote : TextBasedDocumentObject, IVisitable { /// /// Initializes a new instance of the Footnote class. /// - public Footnote() + public Footnote(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new FootnoteValues(this); //NYI: Nested footnote check! @@ -24,7 +24,7 @@ public Footnote() /// /// Initializes a new instance of the Footnote class with the specified parent. /// - internal Footnote(DocumentObject parent) : base(parent) + internal Footnote(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new FootnoteValues(this); } @@ -32,9 +32,9 @@ internal Footnote(DocumentObject parent) : base(parent) /// /// Initializes a new instance of the Footnote class with a text the Footnote shall contain. /// - internal Footnote(string content) : this() + internal Footnote(string content, TextRenderOption textRenderOption = TextRenderOption.Default) : this(textRenderOption) { - Elements.AddParagraph(content); + Elements.AddParagraph(content, textRenderOption); } /// @@ -71,8 +71,8 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the footnote. /// - public Paragraph AddParagraph(string text) - => Elements.AddParagraph(text); + public Paragraph AddParagraph(string text, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddParagraph(text, textRenderOption); /// /// Adds a new table to the footnote. diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/FormattedText.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/FormattedText.cs index 8e525be1..bd3bfd3a 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/FormattedText.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/FormattedText.cs @@ -10,12 +10,12 @@ namespace MigraDoc.DocumentObjectModel /// /// Represents the format of a text. /// - public class FormattedText : DocumentObject, IVisitable + public class FormattedText : TextBasedDocumentObject, IVisitable { /// /// Initializes a new instance of the FormattedText class. /// - public FormattedText() + public FormattedText(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new FormattedTextValues(this); } @@ -23,7 +23,7 @@ public FormattedText() /// /// Initializes a new instance of the FormattedText class with the specified parent. /// - internal FormattedText(DocumentObject parent) : base(parent) + internal FormattedText(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new FormattedTextValues(this); } @@ -67,73 +67,73 @@ public BookmarkField AddBookmark(string name, bool prepend = true) /// Adds a single character repeated the specified number of times to the formatted text. /// public Text AddChar(char ch, int count) - => Elements.AddChar(ch, count); + => Elements.AddChar(ch, count, TextRenderOption); /// /// Adds a single character to the formatted text. /// public Text AddChar(char ch) - => Elements.AddChar(ch); + => Elements.AddChar(ch, TextRenderOption); /// /// Adds a new PageField. /// public PageField AddPageField() - => Elements.AddPageField(); + => Elements.AddPageField(TextRenderOption); /// /// Adds a new PageRefField. /// public PageRefField AddPageRefField(string name) - => Elements.AddPageRefField(name); + => Elements.AddPageRefField(name, TextRenderOption); /// /// Adds a new NumPagesField. /// public NumPagesField AddNumPagesField() - => Elements.AddNumPagesField(); + => Elements.AddNumPagesField(TextRenderOption); /// /// Adds a new SectionField. /// public SectionField AddSectionField() - => Elements.AddSectionField(); + => Elements.AddSectionField(TextRenderOption); /// /// Adds a new SectionPagesField. /// public SectionPagesField AddSectionPagesField() - => Elements.AddSectionPagesField(); + => Elements.AddSectionPagesField(TextRenderOption); /// /// Adds a new DateField. /// public DateField AddDateField() - => Elements.AddDateField(); + => Elements.AddDateField(TextRenderOption); /// /// Adds a new DateField. /// public DateField AddDateField(string format) - => Elements.AddDateField(format); + => Elements.AddDateField(format, TextRenderOption); /// /// Adds a new InfoField. /// public InfoField AddInfoField(InfoFieldType iType) - => Elements.AddInfoField(iType); + => Elements.AddInfoField(iType, TextRenderOption); /// /// Adds a new Footnote with the specified text. /// public Footnote AddFootnote(string text) - => Elements.AddFootnote(text); + => Elements.AddFootnote(text, TextRenderOption); /// /// Adds a new Footnote. /// public Footnote AddFootnote() - => Elements.AddFootnote(); + => Elements.AddFootnote(TextRenderOption); /// /// Adds a text phrase to the formatted text. @@ -141,49 +141,49 @@ public Footnote AddFootnote() /// Content of the new text object. /// Returns a new Text object with the last element of text that was added. public Text AddText(string text) - => Elements.AddText(text); + => Elements.AddText(text, TextRenderOption); /// /// Adds a new FormattedText. /// public FormattedText AddFormattedText() - => Elements.AddFormattedText(); + => Elements.AddFormattedText(TextRenderOption); /// /// Adds a new FormattedText object with the given format. /// public FormattedText AddFormattedText(TextFormat textFormat) - => Elements.AddFormattedText(textFormat); + => Elements.AddFormattedText(textFormat, TextRenderOption); /// /// Adds a new FormattedText with the given Font. /// public FormattedText AddFormattedText(Font font) - => Elements.AddFormattedText(font); + => Elements.AddFormattedText(font, TextRenderOption); /// /// Adds a new FormattedText with the given text. /// public FormattedText AddFormattedText(string text) - => Elements.AddFormattedText(text); + => Elements.AddFormattedText(text, TextRenderOption); /// /// Adds a new FormattedText object with the given text and format. /// public FormattedText AddFormattedText(string text, TextFormat textFormat) - => Elements.AddFormattedText(text, textFormat); + => Elements.AddFormattedText(text, textFormat, TextRenderOption); /// /// Adds a new FormattedText object with the given text and font. /// public FormattedText AddFormattedText(string text, Font font) - => Elements.AddFormattedText(text, font); + => Elements.AddFormattedText(text, font, TextRenderOption); /// /// Adds a new FormattedText object with the given text and style. /// public FormattedText AddFormattedText(string text, string style) - => Elements.AddFormattedText(text, style); + => Elements.AddFormattedText(text, style, TextRenderOption); /// /// Adds a new Hyperlink of Type "Local", i.e. the target is a Bookmark within the Document. @@ -259,43 +259,43 @@ public Image AddImage(string fileName) /// Adds a Symbol object. /// public Character AddCharacter(SymbolName symbolType) - => Elements.AddCharacter(symbolType); + => Elements.AddCharacter(symbolType, TextRenderOption); /// /// Adds one or more Symbol objects. /// public Character AddCharacter(SymbolName symbolType, int count) - => Elements.AddCharacter(symbolType, count); + => Elements.AddCharacter(symbolType, count, TextRenderOption); /// /// Adds a Symbol object defined by a character. /// public Character AddCharacter(char ch) - => Elements.AddCharacter(ch); + => Elements.AddCharacter(ch, TextRenderOption); /// /// Adds one or more Symbol objects defined by a character. /// public Character AddCharacter(char ch, int count) - => Elements.AddCharacter(ch, count); + => Elements.AddCharacter(ch, count, TextRenderOption); /// /// Adds one or more Space characters. /// public Character AddSpace(int count) - => Elements.AddSpace(count); + => Elements.AddSpace(count, TextRenderOption); /// /// Adds a horizontal tab. /// public void AddTab() - => Elements.AddTab(); + => Elements.AddTab(TextRenderOption); /// /// Adds a line break. /// public void AddLineBreak() - => Elements.AddLineBreak(); + => Elements.AddLineBreak(TextRenderOption); /// /// Adds a new Bookmark. diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs index 502f75d7..6dea27e5 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/HeaderFooter.cs @@ -65,9 +65,9 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the header or footer. /// - public Paragraph AddParagraph(string paragraphText) + public Paragraph AddParagraph(string paragraphText, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddParagraph(paragraphText); + return Elements.AddParagraph(paragraphText, textRenderOption); } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs index 85d3052e..3ee696bd 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Hyperlink.cs @@ -135,105 +135,105 @@ public Text AddChar(char ch) /// /// Adds one or more Symbol objects. /// - public Character AddCharacter(SymbolName symbolType, int count) + public Character AddCharacter(SymbolName symbolType, int count, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddCharacter(symbolType, count); + return Elements.AddCharacter(symbolType, count, textRenderOption); } /// /// Adds a Symbol object. /// - public Character AddCharacter(SymbolName symbolType) + public Character AddCharacter(SymbolName symbolType, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddCharacter(symbolType); + return Elements.AddCharacter(symbolType, textRenderOption); } /// /// Adds one or more Symbol objects defined by a character. /// - public Character AddCharacter(char ch, int count) + public Character AddCharacter(char ch, int count, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddCharacter(ch, count); + return Elements.AddCharacter(ch, count, textRenderOption); } /// /// Adds a Symbol object defined by a character. /// - public Character AddCharacter(char ch) + public Character AddCharacter(char ch, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddCharacter(ch); + return Elements.AddCharacter(ch, textRenderOption); } /// /// Adds a space character as many as count. /// - public Character AddSpace(int count) + public Character AddSpace(int count, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddSpace(count); + return Elements.AddSpace(count, textRenderOption); } /// /// Adds a horizontal tab. /// - public void AddTab() + public void AddTab(TextRenderOption textRenderOption = TextRenderOption.Default) { - Elements.AddTab(); + Elements.AddTab(textRenderOption); } /// /// Adds a new FormattedText. /// - public FormattedText AddFormattedText() + public FormattedText AddFormattedText(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(); + return Elements.AddFormattedText(textRenderOption); } /// /// Adds a new FormattedText object with the given format. /// - public FormattedText AddFormattedText(TextFormat textFormat) + public FormattedText AddFormattedText(TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(textFormat); + return Elements.AddFormattedText(textFormat, textRenderOption); } /// /// Adds a new FormattedText with the given Font. /// - public FormattedText AddFormattedText(Font font) + public FormattedText AddFormattedText(Font font, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(font); + return Elements.AddFormattedText(font, textRenderOption); } /// /// Adds a new FormattedText with the given text. /// - public FormattedText AddFormattedText(string text) + public FormattedText AddFormattedText(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(text); + return Elements.AddFormattedText(text, textRenderOption); } /// /// Adds a new FormattedText object with the given text and format. /// - public FormattedText AddFormattedText(string text, TextFormat textFormat) + public FormattedText AddFormattedText(string text, TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(text, textFormat); + return Elements.AddFormattedText(text, textFormat, textRenderOption); } /// /// Adds a new FormattedText object with the given text and font. /// - public FormattedText AddFormattedText(string text, Font font) + public FormattedText AddFormattedText(string text, Font font, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(text, font); + return Elements.AddFormattedText(text, font, textRenderOption); } /// /// Adds a new FormattedText object with the given text and style. /// - public FormattedText AddFormattedText(string text, string style) + public FormattedText AddFormattedText(string text, string style, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFormattedText(text, style); + return Elements.AddFormattedText(text, style, textRenderOption); } /// @@ -249,81 +249,81 @@ public BookmarkField AddBookmark(string name, bool prepend = true) /// /// Adds a new PageField. /// - public PageField AddPageField() + public PageField AddPageField(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddPageField(); + return Elements.AddPageField(textRenderOption); } /// /// Adds a new PageRefField. /// - public PageRefField AddPageRefField(string name) + public PageRefField AddPageRefField(string name, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddPageRefField(name); + return Elements.AddPageRefField(name, textRenderOption); } /// /// Adds a new NumPagesField. /// - public NumPagesField AddNumPagesField() + public NumPagesField AddNumPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddNumPagesField(); + return Elements.AddNumPagesField(textRenderOption); } /// /// Adds a new SectionField. /// - public SectionField AddSectionField() + public SectionField AddSectionField(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddSectionField(); + return Elements.AddSectionField(textRenderOption); } /// /// Adds a new SectionPagesField. /// - public SectionPagesField AddSectionPagesField() + public SectionPagesField AddSectionPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddSectionPagesField(); + return Elements.AddSectionPagesField(textRenderOption); } /// /// Adds a new DateField. /// - public DateField AddDateField() + public DateField AddDateField(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddDateField(); + return Elements.AddDateField(textRenderOption); } /// /// Adds a new DateField. /// - public DateField AddDateField(string format) + public DateField AddDateField(string format, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddDateField(format); + return Elements.AddDateField(format, textRenderOption); } /// /// Adds a new InfoField. /// - public InfoField AddInfoField(InfoFieldType iType) + public InfoField AddInfoField(InfoFieldType iType, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddInfoField(iType); + return Elements.AddInfoField(iType, textRenderOption); } /// /// Adds a new Footnote with the specified text. /// - public Footnote AddFootnote(string text) + public Footnote AddFootnote(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFootnote(text); + return Elements.AddFootnote(text, textRenderOption); } /// /// Adds a new Footnote. /// - public Footnote AddFootnote() + public Footnote AddFootnote(TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddFootnote(); + return Elements.AddFootnote(textRenderOption); } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs index 7d39ba56..b854341c 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Paragraph.cs @@ -57,104 +57,104 @@ protected override object DeepCopy() /// Adds a text phrase to the paragraph. /// /// Returns a new Text object with the last element of text that was added. - public Text AddText(string text) - => Elements.AddText(text); + public Text AddText(string text, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddText(text, textRenderOption); /// /// Adds a single character repeated the specified number of times to the paragraph. /// - public Text AddChar(char ch, int count) - => Elements.AddChar(ch, count); + public Text AddChar(char ch, int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddChar(ch, count, textRenderOption); /// /// Adds a single character to the paragraph. /// - public Text AddChar(char ch) - => Elements.AddChar(ch); + public Text AddChar(char ch, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddChar(ch, textRenderOption); /// /// Adds one or more Symbol objects. /// - public Character AddCharacter(SymbolName symbolType, int count) - => Elements.AddCharacter(symbolType, count); + public Character AddCharacter(SymbolName symbolType, int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddCharacter(symbolType, count, textRenderOption); /// /// Adds a Symbol object. /// - public Character AddCharacter(SymbolName symbolType) - => Elements.AddCharacter(symbolType); + public Character AddCharacter(SymbolName symbolType, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddCharacter(symbolType, textRenderOption); /// /// Adds one or more Symbol objects defined by a character. /// - public Character AddCharacter(char ch, int count) - => Elements.AddCharacter(ch, count); + public Character AddCharacter(char ch, int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddCharacter(ch, count, textRenderOption); /// /// Adds a Symbol object defined by a character. /// - public Character AddCharacter(char ch) - => Elements.AddCharacter(ch); + public Character AddCharacter(char ch, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddCharacter(ch, textRenderOption); /// /// Adds a space character as many as count. /// - public Character AddSpace(int count) - => Elements.AddSpace(count); + public Character AddSpace(int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddSpace(count, textRenderOption); /// /// Adds a horizontal tab. /// - public void AddTab() - => Elements.AddTab(); + public void AddTab(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddTab(textRenderOption); /// /// Adds a line break. /// - public void AddLineBreak() - => Elements.AddLineBreak(); + public void AddLineBreak(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddLineBreak(textRenderOption); /// /// Adds a new FormattedText. /// - public FormattedText AddFormattedText() - => Elements.AddFormattedText(); + public FormattedText AddFormattedText(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(textRenderOption); /// /// Adds a new FormattedText object with the given format. /// - public FormattedText AddFormattedText(TextFormat textFormat) - => Elements.AddFormattedText(textFormat); + public FormattedText AddFormattedText(TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(textFormat, textRenderOption); /// /// Adds a new FormattedText with the given Font. /// - public FormattedText AddFormattedText(Font font) - => Elements.AddFormattedText(font); + public FormattedText AddFormattedText(Font font, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(font, textRenderOption); /// /// Adds a new FormattedText with the given text. /// - public FormattedText AddFormattedText(string text) - => Elements.AddFormattedText(text); + public FormattedText AddFormattedText(string text, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(text, textRenderOption); /// /// Adds a new FormattedText object with the given text and format. /// - public FormattedText AddFormattedText(string text, TextFormat textFormat) - => Elements.AddFormattedText(text, textFormat); + public FormattedText AddFormattedText(string text, TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(text, textFormat, textRenderOption); /// /// Adds a new FormattedText object with the given text and font. /// - public FormattedText AddFormattedText(string text, Font font) - => Elements.AddFormattedText(text, font); + public FormattedText AddFormattedText(string text, Font font, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(text, font, textRenderOption); /// /// Adds a new FormattedText object with the given text and style. /// - public FormattedText AddFormattedText(string text, string style) - => Elements.AddFormattedText(text, style); + public FormattedText AddFormattedText(string text, string style, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFormattedText(text, style, textRenderOption); /// /// Adds a new Hyperlink of Type "Local", i.e. the target is a Bookmark within the Document. @@ -228,62 +228,62 @@ public BookmarkField AddBookmark(string name, bool prepend = true) /// /// Adds a new PageField. /// - public PageField AddPageField() - => Elements.AddPageField(); + public PageField AddPageField(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddPageField(textRenderOption); /// /// Adds a new PageRefField. /// - public PageRefField AddPageRefField(string name) - => Elements.AddPageRefField(name); + public PageRefField AddPageRefField(string name, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddPageRefField(name, textRenderOption); /// /// Adds a new NumPagesField. /// - public NumPagesField AddNumPagesField() - => Elements.AddNumPagesField(); + public NumPagesField AddNumPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddNumPagesField(textRenderOption); /// /// Adds a new SectionField. /// - public SectionField AddSectionField() - => Elements.AddSectionField(); + public SectionField AddSectionField(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddSectionField(textRenderOption); /// /// Adds a new SectionPagesField. /// - public SectionPagesField AddSectionPagesField() - => Elements.AddSectionPagesField(); + public SectionPagesField AddSectionPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddSectionPagesField(textRenderOption); /// /// Adds a new DateField. /// - public DateField AddDateField() - => Elements.AddDateField(); + public DateField AddDateField(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddDateField(textRenderOption); /// /// Adds a new DateField. /// - public DateField AddDateField(string format) - => Elements.AddDateField(format); + public DateField AddDateField(string format, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddDateField(format, textRenderOption); /// /// Adds a new InfoField. /// - public InfoField AddInfoField(InfoFieldType iType) - => Elements.AddInfoField(iType); + public InfoField AddInfoField(InfoFieldType iType, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddInfoField(iType, textRenderOption); /// /// Adds a new Footnote with the specified text. /// - public Footnote AddFootnote(string text) - => Elements.AddFootnote(text); + public Footnote AddFootnote(string text, TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFootnote(text, textRenderOption); /// /// Adds a new Footnote. /// - public Footnote AddFootnote() - => Elements.AddFootnote(); + public Footnote AddFootnote(TextRenderOption textRenderOption = TextRenderOption.Default) + => Elements.AddFootnote(textRenderOption); /// /// Adds a new Image object. diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/ParagraphElements.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/ParagraphElements.cs index 8386cb09..8210d6db 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/ParagraphElements.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/ParagraphElements.cs @@ -43,8 +43,9 @@ internal ParagraphElements(DocumentObject parent) : base(parent) /// The function returns the last text object that was created. /// /// Contents of the new Text objects. + /// RenderOption for the new Text objects. /// Returns a new Text object with the last element of text that was added. - public Text AddText(string text) + public Text AddText(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { if (text == null) throw new ArgumentNullException(nameof(text)); @@ -59,13 +60,13 @@ public Text AddText(string text) { if (tabParts[idx].Length != 0) { - Add(result = new(tabParts[idx])); + Add(result = new(tabParts[idx], textRenderOption)); } if (idx < count - 1) - AddTab(); + AddTab(textRenderOption); } if (line < lineCount - 1) - AddLineBreak(); + AddLineBreak(textRenderOption); } return result; } @@ -73,27 +74,27 @@ public Text AddText(string text) /// /// Adds a single character repeated the specified number of times to the paragraph. /// - public Text AddChar(char ch, int count) - => AddText(new string(ch, count)); + public Text AddChar(char ch, int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddText(new string(ch, count), textRenderOption); /// /// Adds a single character to the paragraph. /// - public Text AddChar(char ch) - => AddText(new string(ch, 1)); + public Text AddChar(char ch, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddText(new string(ch, 1), textRenderOption); /// /// Adds a Character object. /// - public Character AddCharacter(SymbolName symbolType) - => AddCharacter(symbolType, 1); + public Character AddCharacter(SymbolName symbolType, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter(symbolType, 1, textRenderOption); /// /// Adds one or more Character objects. /// - public Character AddCharacter(SymbolName symbolType, int count) + public Character AddCharacter(SymbolName symbolType, int count, TextRenderOption textRenderOption = TextRenderOption.Default) { - var character = new Character(); + var character = new Character(textRenderOption); Add(character); character.SymbolName = symbolType; character.Count = count; @@ -103,39 +104,39 @@ public Character AddCharacter(SymbolName symbolType, int count) /// /// Adds a Character object defined by a character. /// - public Character AddCharacter(char ch) - => AddCharacter((SymbolName)ch, 1); + public Character AddCharacter(char ch, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter((SymbolName)ch, 1, textRenderOption); /// /// Adds one or more Character objects defined by a character. /// - public Character AddCharacter(char ch, int count) - => AddCharacter((SymbolName)ch, count); + public Character AddCharacter(char ch, int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter((SymbolName)ch, count, textRenderOption); /// /// Adds a space character as many as count. /// - public Character AddSpace(int count) - => AddCharacter(SymbolName.Blank, count); + public Character AddSpace(int count, TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter(SymbolName.Blank, count, textRenderOption); /// /// Adds a horizontal tab. /// - public Character AddTab() - => AddCharacter(SymbolName.Tab, 1); + public Character AddTab(TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter(SymbolName.Tab, 1, textRenderOption); /// /// Adds a line break. /// - public Character AddLineBreak() - => AddCharacter(SymbolName.LineBreak, 1); + public Character AddLineBreak(TextRenderOption textRenderOption = TextRenderOption.Default) + => AddCharacter(SymbolName.LineBreak, 1, textRenderOption); /// /// Adds a new FormattedText. /// - public FormattedText AddFormattedText() + public FormattedText AddFormattedText(TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = new FormattedText(); + var formattedText = new FormattedText(textRenderOption); Add(formattedText); return formattedText; } @@ -143,9 +144,9 @@ public FormattedText AddFormattedText() /// /// Adds a new FormattedText object with the given format. /// - public FormattedText AddFormattedText(TextFormat textFormat) + public FormattedText AddFormattedText(TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = AddFormattedText(); + var formattedText = AddFormattedText(textRenderOption); if ((textFormat & TextFormat.Bold) == TextFormat.Bold) formattedText.Bold = true; @@ -166,9 +167,9 @@ public FormattedText AddFormattedText(TextFormat textFormat) /// /// Adds a new FormattedText with the given Font. /// - public FormattedText AddFormattedText(Font font) + public FormattedText AddFormattedText(Font font, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = new FormattedText(); + var formattedText = new FormattedText(textRenderOption); formattedText.Font.ApplyFont(font); Add(formattedText); return formattedText; @@ -177,9 +178,9 @@ public FormattedText AddFormattedText(Font font) /// /// Adds a new FormattedText with the given text. /// - public FormattedText AddFormattedText(string text) + public FormattedText AddFormattedText(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = new FormattedText(); + var formattedText = new FormattedText(textRenderOption); formattedText.AddText(text); Add(formattedText); return formattedText; @@ -188,9 +189,9 @@ public FormattedText AddFormattedText(string text) /// /// Adds a new FormattedText object with the given text and format. /// - public FormattedText AddFormattedText(string text, TextFormat textFormat) + public FormattedText AddFormattedText(string text, TextFormat textFormat, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = AddFormattedText(textFormat); + var formattedText = AddFormattedText(textFormat, textRenderOption); formattedText.AddText(text); return formattedText; } @@ -198,9 +199,9 @@ public FormattedText AddFormattedText(string text, TextFormat textFormat) /// /// Adds a new FormattedText object with the given text and font. /// - public FormattedText AddFormattedText(string text, Font font) + public FormattedText AddFormattedText(string text, Font font, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = AddFormattedText(font); + var formattedText = AddFormattedText(font, textRenderOption); formattedText.AddText(text); return formattedText; } @@ -208,9 +209,9 @@ public FormattedText AddFormattedText(string text, Font font) /// /// Adds a new FormattedText object with the given text and style. /// - public FormattedText AddFormattedText(string text, string style) + public FormattedText AddFormattedText(string text, string style, TextRenderOption textRenderOption = TextRenderOption.Default) { - var formattedText = AddFormattedText(text); + var formattedText = AddFormattedText(text, textRenderOption); formattedText.Style = style; return formattedText; } @@ -349,9 +350,9 @@ public BookmarkField AddBookmark(string name, bool prepend = true) /// /// Adds a new PageField. /// - public PageField AddPageField() + public PageField AddPageField(TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldPage = new PageField(); + var fieldPage = new PageField(textRenderOption); Add(fieldPage); return fieldPage; } @@ -359,9 +360,9 @@ public PageField AddPageField() /// /// Adds a new RefFieldPage. /// - public PageRefField AddPageRefField(string name) + public PageRefField AddPageRefField(string name, TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldPageRef = new PageRefField + var fieldPageRef = new PageRefField(textRenderOption) { Name = name }; @@ -372,9 +373,9 @@ public PageRefField AddPageRefField(string name) /// /// Adds a new NumPagesField. /// - public NumPagesField AddNumPagesField() + public NumPagesField AddNumPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldNumPages = new NumPagesField(); + var fieldNumPages = new NumPagesField(textRenderOption); Add(fieldNumPages); return fieldNumPages; } @@ -382,9 +383,9 @@ public NumPagesField AddNumPagesField() /// /// Adds a new SectionField. /// - public SectionField AddSectionField() + public SectionField AddSectionField(TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldSection = new SectionField(); + var fieldSection = new SectionField(textRenderOption); Add(fieldSection); return fieldSection; } @@ -392,9 +393,9 @@ public SectionField AddSectionField() /// /// Adds a new SectionPagesField. /// - public SectionPagesField AddSectionPagesField() + public SectionPagesField AddSectionPagesField(TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldSectionPages = new SectionPagesField(); + var fieldSectionPages = new SectionPagesField(textRenderOption); Add(fieldSectionPages); return fieldSectionPages; } @@ -403,9 +404,9 @@ public SectionPagesField AddSectionPagesField() /// Adds a new DateField. /// /// - public DateField AddDateField() + public DateField AddDateField(TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldDate = new DateField(); + var fieldDate = new DateField(textRenderOption); Add(fieldDate); return fieldDate; } @@ -413,9 +414,9 @@ public DateField AddDateField() /// /// Adds a new DateField with the given format. /// - public DateField AddDateField(string format) + public DateField AddDateField(string format, TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldDate = new DateField + var fieldDate = new DateField(textRenderOption) { Format = format }; @@ -426,9 +427,9 @@ public DateField AddDateField(string format) /// /// Adds a new InfoField with the given type. /// - public InfoField AddInfoField(InfoFieldType iType) + public InfoField AddInfoField(InfoFieldType iType, TextRenderOption textRenderOption = TextRenderOption.Default) { - var fieldInfo = new InfoField + var fieldInfo = new InfoField(textRenderOption) { Name = iType.ToString() }; @@ -439,11 +440,11 @@ public InfoField AddInfoField(InfoFieldType iType) /// /// Adds a new Footnote with the specified Text. /// - public Footnote AddFootnote(string text) + public Footnote AddFootnote(string text, TextRenderOption textRenderOption = TextRenderOption.Default) { - var footnote = new Footnote(); + var footnote = new Footnote(textRenderOption); var par = footnote.Elements.AddParagraph(); - par.AddText(text); + par.AddText(text, textRenderOption); Add(footnote); return footnote; } @@ -451,9 +452,9 @@ public Footnote AddFootnote(string text) /// /// Adds a new Footnote. /// - public Footnote AddFootnote() + public Footnote AddFootnote(TextRenderOption textRenderOption = TextRenderOption.Default) { - var footnote = new Footnote(); + var footnote = new Footnote(textRenderOption); Add(footnote); return footnote; } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs index eeeaa8ee..a95f121c 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Section.cs @@ -89,17 +89,17 @@ public Paragraph AddParagraph() /// /// Adds a new paragraph with the specified text to the section. /// - public Paragraph AddParagraph(string paragraphText) + public Paragraph AddParagraph(string paragraphText, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddParagraph(paragraphText); + return Elements.AddParagraph(paragraphText, textRenderOption); } /// /// Adds a new paragraph with the specified text and style to the section. /// - public Paragraph AddParagraph(string paragraphText, string style) + public Paragraph AddParagraph(string paragraphText, string style, TextRenderOption textRenderOption = TextRenderOption.Default) { - return Elements.AddParagraph(paragraphText, style); + return Elements.AddParagraph(paragraphText, style, textRenderOption); } /// diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs index 33c072a6..ce164b6c 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/Text.cs @@ -6,12 +6,12 @@ namespace MigraDoc.DocumentObjectModel /// /// Represents text in a paragraph. /// - public class Text : DocumentObject + public class Text : TextBasedDocumentObject { /// /// Initializes a new instance of the Text class. /// - public Text() + public Text(TextRenderOption textRenderOption = TextRenderOption.Default) : base(textRenderOption) { BaseValues = new TextValues(this); } @@ -19,7 +19,7 @@ public Text() /// /// Initializes a new instance of the Text class with the specified parent. /// - internal Text(DocumentObject parent) : base(parent) + internal Text(DocumentObject parent, TextRenderOption textRenderOption = TextRenderOption.Default) : base(parent, textRenderOption) { BaseValues = new TextValues(this); } @@ -27,7 +27,7 @@ internal Text(DocumentObject parent) : base(parent) /// /// Initializes a new instance of the Text class with a string as paragraph content. /// - public Text(string content) : this() + public Text(string content, TextRenderOption textRenderOption = TextRenderOption.Default) : this(textRenderOption) { Content = content; } diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/TextBasedDocumentObject.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/TextBasedDocumentObject.cs new file mode 100644 index 00000000..bba11fb2 --- /dev/null +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/TextBasedDocumentObject.cs @@ -0,0 +1,38 @@ +namespace MigraDoc.DocumentObjectModel +{ + /// + /// Base class of document objects that contain text. + /// + public abstract class TextBasedDocumentObject : DocumentObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The text render option. + /// + protected TextBasedDocumentObject(TextRenderOption textRenderOption) + { + TextRenderOption = textRenderOption; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Document object. + /// + /// + /// The text render option. + /// + protected TextBasedDocumentObject(DocumentObject parent, TextRenderOption textRenderOption) : base(parent) + { + TextRenderOption = textRenderOption; + } + + /// + /// Gets or sets the text render option. + /// + public TextRenderOption TextRenderOption { get; private set; } + } +} \ No newline at end of file diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/enums/TextRenderOption.cs b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/enums/TextRenderOption.cs new file mode 100644 index 00000000..bfc3bfb5 --- /dev/null +++ b/src/foundation/src/MigraDoc/src/MigraDoc.DocumentObjectModel/DocumentObjectModel/enums/TextRenderOption.cs @@ -0,0 +1,25 @@ + +namespace MigraDoc.DocumentObjectModel +{ + /// + /// Specifies the option for rendering text. + /// + public enum TextRenderOption + { + /// + /// Text will be rendered as text. + /// + Default = 0, + + /// + /// Text will be rendered as path. + /// + Path, + + /// + /// Text will be rendered as path and the path will be flattened. + /// The size will be reduced by flattening the path. + /// + FlattenPath + } +} \ No newline at end of file diff --git a/src/foundation/src/MigraDoc/src/MigraDoc.Rendering/Rendering/ParagraphRenderer.cs b/src/foundation/src/MigraDoc/src/MigraDoc.Rendering/Rendering/ParagraphRenderer.cs index 45ef3511..9eace224 100644 --- a/src/foundation/src/MigraDoc/src/MigraDoc.Rendering/Rendering/ParagraphRenderer.cs +++ b/src/foundation/src/MigraDoc/src/MigraDoc.Rendering/Rendering/ParagraphRenderer.cs @@ -901,7 +901,7 @@ void RenderElement(DocumentObject docObj) break; } if (IsSoftHyphen(obj)) - RenderSoftHyphen(); + RenderSoftHyphen(obj.TextRenderOption); else RenderBlank(); //if (IsBlank(docObj)) @@ -981,32 +981,32 @@ void RenderDateField(DateField dateField) if (_fieldInfos is null) NRT.ThrowOnNull(); var value = FormatDateTimeForField(_fieldInfos.Date, dateField); - RenderWord(value); + RenderWord(value, dateField.TextRenderOption); } void RenderInfoField(InfoField infoField) { - RenderWord(GetDocumentInfo(infoField.Name)); + RenderWord(GetDocumentInfo(infoField.Name), infoField.TextRenderOption); } void RenderNumPagesField(NumPagesField numPagesField) { - RenderWord(GetFieldValue(numPagesField)); + RenderWord(GetFieldValue(numPagesField), numPagesField.TextRenderOption); } void RenderPageField(PageField pageField) { - RenderWord(GetFieldValue(pageField)); + RenderWord(GetFieldValue(pageField), pageField.TextRenderOption); } void RenderSectionField(SectionField sectionField) { - RenderWord(GetFieldValue(sectionField)); + RenderWord(GetFieldValue(sectionField), sectionField.TextRenderOption); } void RenderSectionPagesField(SectionPagesField sectionPagesField) { - RenderWord(GetFieldValue(sectionPagesField)); + RenderWord(GetFieldValue(sectionPagesField), sectionPagesField.TextRenderOption); } void RenderBookmarkField(BookmarkField bookmarkField) @@ -1047,7 +1047,7 @@ XPoint GetDestinationPosition() void RenderPageRefField(PageRefField pageRefField) { - RenderWord(GetFieldValue(pageRefField)); + RenderWord(GetFieldValue(pageRefField), TextRenderOption.Default); } void RenderCharacter(Character character) @@ -1095,7 +1095,7 @@ void RenderSymbol(Character character) for (int idx = 1; idx < character.Count; idx++) completeWord += sym; - RenderWord(completeWord); + RenderWord(completeWord, character.TextRenderOption); } void RenderTab() @@ -1217,21 +1217,21 @@ void RenderBlank() } } - void RenderSoftHyphen() + void RenderSoftHyphen(TextRenderOption textRenderOption) { if (_currentLeaf is null || _endLeaf is null) NRT.ThrowOnNull(); if (_currentLeaf.Current == _endLeaf.Current) - RenderWord("-"); + RenderWord("-", textRenderOption); } void RenderText(Text text) { - RenderWord(text.Content); + RenderWord(text.Content, text.TextRenderOption); } - void RenderWord(string word) + void RenderWord(string word, TextRenderOption textRenderOption) { Font font = CurrentDomFont; XFont xFont = CurrentFont; @@ -1239,13 +1239,51 @@ void RenderWord(string word) xFont = FontHandler.ToSubSuperFont(xFont); if (CurrentBrush != null) - _gfx.DrawString(word, xFont, CurrentBrush, _currentXPosition, CurrentBaselinePosition); + { + switch (textRenderOption) + { + case TextRenderOption.Path: + case TextRenderOption.FlattenPath: + RenderAsPath(word, textRenderOption, xFont, font); + break; + default: + RenderAsText(word, xFont); + break; + } + } XUnitPt wordWidth = MeasureString(word); RenderUnderline(wordWidth, true); RealizeHyperlink(wordWidth); _currentXPosition += wordWidth; } + private void RenderAsText(string word, XFont xFont) + { + _gfx.DrawString(word, xFont, CurrentBrush, _currentXPosition, CurrentBaselinePosition); + } + + private void RenderAsPath(string word, TextRenderOption textRenderOption, XFont xFont, Font font) + { + var currentBaselinePosition = CurrentBaselinePosition.Point; + + var path = new XGraphicsPath(); + path.AddString( + word, + xFont.FontFamily, + xFont.Style, + xFont.Size, + new XPoint(_currentXPosition, currentBaselinePosition), + XStringFormats.Default); + var fill = new XSolidBrush(XColor.FromArgb(font.Color.Argb)); + + if (textRenderOption == TextRenderOption.FlattenPath) + { + path.Flatten(); + } + + _gfx.DrawPath(fill, path); + } + void StartHyperlink(XUnitPt left, XUnitPt top) { _hyperlinkRect = new XRect(left, top, 0, 0); diff --git a/src/foundation/src/MigraDoc/tests/MigraDoc.DocumentObjectModel.Tests/valuemodel/ConsistenceTests.cs b/src/foundation/src/MigraDoc/tests/MigraDoc.DocumentObjectModel.Tests/valuemodel/ConsistenceTests.cs index d40fbaea..dd3a52e3 100644 --- a/src/foundation/src/MigraDoc/tests/MigraDoc.DocumentObjectModel.Tests/valuemodel/ConsistenceTests.cs +++ b/src/foundation/src/MigraDoc/tests/MigraDoc.DocumentObjectModel.Tests/valuemodel/ConsistenceTests.cs @@ -65,7 +65,16 @@ public void Create_all_Metas_and_check_ValueDescriptors() { type.IsAbstract.Should().BeFalse(); - var dom = (DocumentObject?)Activator.CreateInstance(type); + DocumentObject dom; + if (type.IsSubclassOf(typeof(TextBasedDocumentObject))) + { + dom = (TextBasedDocumentObject?)Activator.CreateInstance(type, TextRenderOption.Default); + } + else + { + dom = (DocumentObject?)Activator.CreateInstance(type); + } + dom.Should().NotBeNull(); var meta = dom!.Meta; meta.Should().NotBeNull(); diff --git a/src/foundation/src/MigraDoc/tests/MigraDoc.Tests/TextTests.cs b/src/foundation/src/MigraDoc/tests/MigraDoc.Tests/TextTests.cs index 9d8c0066..fba84359 100644 --- a/src/foundation/src/MigraDoc/tests/MigraDoc.Tests/TextTests.cs +++ b/src/foundation/src/MigraDoc/tests/MigraDoc.Tests/TextTests.cs @@ -456,5 +456,114 @@ public void FooterLayoutTest() //// ...and start a viewer. //Process.Sta/rt(new ProcessStartInfo(filename) { UseShellExecute = true }); } + + [Theory()] + [InlineData(true, true)] + [InlineData(true, false)] + [InlineData(false, false)] + public void RenderTextAsPathTest(bool isRenderAsPath, bool isFlattenPath) + { + var document = new Document(); + + var style = document.Styles[StyleNames.Heading1]; + style!.Font.Size = Unit.FromPoint(14); + style.Font.Bold = true; + + var section = document.AddSection(); + + // Leave 10 cm for content. + section.PageSetup.TopMargin = Unit.FromCentimeter(5); + section.PageSetup.BottomMargin = Unit.FromCentimeter(8); + + var textRenderOption = isRenderAsPath switch + { + true when isFlattenPath => TextRenderOption.FlattenPath, + true => TextRenderOption.Path, + _ => TextRenderOption.Default + }; + + // Add test paragraph. + var p = section.AddParagraph("Paragraph one", textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddChar('C', textRenderOption); + p.AddSpace(3, textRenderOption); + p.AddCharacter(SymbolName.Copyright, textRenderOption); + p.AddTab(textRenderOption); + p.AddCharacter('C', textRenderOption); + p.AddCharacter('h', textRenderOption); + p.AddLineBreak(textRenderOption); + var ft = p.AddFormattedText(textRenderOption); + ft.AddText("Formatted Text"); + p.AddTab(textRenderOption); + p.AddTab(textRenderOption); + p.AddTab(textRenderOption); + ft = p.AddFormattedText(TextFormat.Bold, textRenderOption); + ft.AddText("Formatted Bold Text"); + p.AddLineBreak(textRenderOption); + var font = new Font("Times New Roman", 20); + ft = p.AddFormattedText(font, textRenderOption); + ft.AddText("Formatted Text with Font"); + p.AddLineBreak(textRenderOption); + p.AddFormattedText("Formatted Text one", textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddFormattedText("Formatted Text two", TextFormat.Underline, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddFormattedText("Formatted Text three", font, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddFormattedText("Formatted Text four", StyleNames.Heading4, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddText("Section: ", textRenderOption); + p.AddSectionField(textRenderOption).Format = "alphabetic"; + p.AddLineBreak(textRenderOption); + p.AddText("Footnote: ", textRenderOption); + p.AddFootnote(textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddText("Page: ", textRenderOption); + p.AddPageField(textRenderOption).Format = "ROMAN"; + p.AddLineBreak(textRenderOption); + p.AddText("NumPages: ", textRenderOption); + p.AddNumPagesField(textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddText("Date: ", textRenderOption); + p.AddDateField(textRenderOption); + p.AddLineBreak(textRenderOption); + p.Format.LineSpacingRule = LineSpacingRule.Exactly; + p.Format.LineSpacing = Unit.FromCentimeter(1); + p.Format.Shading.Color = Colors.LightBlue; + p = section.AddParagraph("Paragraph two", StyleNames.Heading3, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddChar('C', 2, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddCharacter(SymbolName.Copyright, 2, textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddText("SectionPages: ", textRenderOption); + p.AddSectionPagesField(textRenderOption).Format = "alphabetic"; + p.AddLineBreak(textRenderOption); + p.AddText("Bookmark: ", textRenderOption); + p.AddBookmark("page"); + p.AddLineBreak(textRenderOption); + p.AddText("PageRef: ", textRenderOption); + p.AddPageRefField("page", textRenderOption).Format = "ROMAN"; + p.AddLineBreak(textRenderOption); + p.AddText("Footnote: ", textRenderOption); + p.AddFootnote("Foot", textRenderOption); + p.AddLineBreak(textRenderOption); + p.AddText("Date: ", textRenderOption); + p.AddDateField("yyyy-MM-dd", textRenderOption); + p.AddLineBreak(textRenderOption); + p.Format.LineSpacingRule = LineSpacingRule.Exactly; + p.Format.LineSpacing = Unit.FromCentimeter(1); + p.Format.Shading.Color = Colors.LightGray; + + // Render document and add it to sumDoc. + var pdfRenderer = new PdfDocumentRenderer { Document = document }; + pdfRenderer.RenderDocument(); + + // Save the document... + var filename = PdfFileUtility.GetTempPdfFileName("RenderTextAsPathTest"); + pdfRenderer.PdfDocument.Save(filename); + // ...and start a viewer. + PdfFileUtility.ShowDocumentIfDebugging(filename); + } } }