How to pass styles while adding text to headers and footers. We were trying it in below mentioned way. The styling is not taking effect.
image.png (158.1 KB)
Regards,
Nipun Jain
How to pass styles while adding text to headers and footers. We were trying it in below mentioned way. The styling is not taking effect.
image.png (158.1 KB)
Regards,
Nipun Jain
You are using the wrong API for adding Style to Header/Footer.
With the following API, you can change document styles or text properties (size, colour etc):
Here is an example:
name = SampleDocument_Result.docx
fontDto = {
“AllCaps”: false,
“Bidi”: false,
“Bold”: true,
“BoldBi”: false,
“Border”: {
“LineStyle”: “None”,
“LineWidth”: 0,
“Color”: {
“@Web”: “”,
“@Alpha”: 0
},
“DistanceFromText”: 0,
“Shadow”: false
},
“Color”: {
“@Web”: “”,
“@Alpha”: 0
},
“ComplexScript”: false,
“DoubleStrikeThrough”: false,
“Emboss”: false,
“Engrave”: false,
“Hidden”: false,
“HighlightColor”: {
“@Web”: “”,
“@Alpha”: 0
},
“Italic”: true,
“ItalicBi”: false,
“Kerning”: 0,
“LocaleId”: 1033,
“LocaleIdBi”: 1025,
“LocaleIdFarEast”: 1033,
“Name”: “Calibri”,
“NameAscii”: “Calibri”,
“NameBi”: “Times New Roman”,
“NameFarEast”: “Calibri”,
“NameOther”: “Calibri”,
“NoProofing”: false,
“Outline”: false,
“Position”: 0,
“Scaling”: 100,
“Shadow”: false,
“Size”: 11,
“SizeBi”: 11,
“SmallCaps”: false,
“Spacing”: 0,
“StrikeThrough”: false,
“StyleIdentifier”: “DefaultParagraphFont”,
“StyleName”: “Default Paragraph Font”,
“Subscript”: false,
“Superscript”: false,
“TextEffect”: “None”,
“Underline”: “Dash”,
“UnderlineColor”: {
“@Web”: “#A5A5A5”
}
}
paragraphPath = sections/0/headersfooters/0/paragraphs/0
index = 0
Input Document: Dropbox - SampleDocument.docx - Simplify your life
Output Document: Dropbox - SampleDocument_Result.docx - Simplify your life
Following is the description of Font object attributes:
|Property Name |Type |Description |
|—|—|—|—|—|
|AllCaps |bool |True if the font is formatted as all capital letters. |RW |AllCaps|
|Bidi |bool |Specifies whether the contents of this run shall have right-to-left characteristics. |RW |Bidi|
|Bold |bool |True if the font is formatted as bold. |RW |Bold|
|BoldBi |bool |True if the right-to-left text is formatted as bold. |RW |BoldBi|
|Border |Border |Border object that specifies border for the font. |RW |Border|
|Color |Color |Gets or sets the color of the font. |RW |Color|
|ComplexScript |bool |Specifies whether the contents of this run shall be treated as complex script text regardless of their Unicode character values when determining the formatting for this run. |RW |ComplexScript|
|DoubleStrikeThrough |bool |True if the font is formatted as double strikethrough text. |RW |DoubleStrikeThrough|
|Emboss |bool |True if the font is formatted as embossed. |RW |Emboss|
|Engrave |bool |True if the font is formatted as engraved. |RW |Engrave|
|Hidden |bool |True if the font is formatted as hidden text. |RW |Hidden|
|HighlightColor |Color |Gets or sets the highlight (marker) color. |RW |HighlightColor|
|Italic |bool |True if the font is formatted as italic. |RW |Italic|
|ItalicBi |bool |True if the right-to-left text is formatted as italic. |RW |ItalicBi|
|Kerning |double |Gets or sets the font size at which kerning starts. |RW |Kerning|
|LocaleId |int |Gets or sets the locale identifier (language) of the formatted characters. For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
|RW |LocaleId|
|LocaleIdBi |int |Gets or sets the locale identifier (language) of the formatted right-to-left characters. For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
|RW |LocaleIdBi|
|LocaleIdFarEast |int |Gets or sets the locale identifier (language) of the formatted Asian characters. For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
|RW |LocaleIdFarEast|
|Name |string |Gets or sets the name of the font. |RW |Name|
|NameAscii |bool |Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127). |RW |NameAscii|
|NameBi |bool |TReturns or sets the name of the font in a right-to-left language document. |RW |NameBi|
|NameFarEast |bool |Returns or sets an East Asian font name. |RW |NameFarEast|
|NameOther |bool |Returns or sets the font used for characters with character codes from 128 through 255. |RW |NameOther|
|NoProofing |bool |True when the formatted characters are not to be spell checked. |RW |NoProofing|
|Outline |bool |True if the font is formatted as outline. |RW |Outline|
|Position |double |Gets or sets the position of text (in points) relative to the base line. A positive number raises the text, and a negative number lowers it. |RW |Position|
|Scaling |int |Gets or sets character width scaling in percent. |RW |Scaling|
|Shadow |bool |True if the font is formatted as shadowed. |RW |Shadow|
|Size |double |Gets or sets the font size in points. |RW |Size|
|SizeBi |double |Gets or sets the font size in points used in a right-to-left document. |RW |SizeBi|
|SmallCaps |bool |True if the font is formatted as small capital letters. |RW |SmallCaps|
|Spacing |double |Returns or sets the spacing (in points) between characters. |RW |Spacing|
|StrikeThrough |bool |True if the font is formatted as strikethrough text. |RW |StrikeThrough|
|StyleIdentifier |StyleIdentifier |Gets or sets the locale independent style identifier of the character style applied to this formatting. |RW |StyleIdentifier|
|StyleName |string |Gets or sets the name of the character style applied to this formatting. |RW |StyleName|
|Subscript |bool |True if the font is formatted as subscript. |RW |Subscript|
|Superscript |bool |True if the font is formatted as superscript. |RW |Superscript|
|TextEffect |TextEffect |Gets or sets the font animation effect. |RW |TextEffect|
|Underline |Underline |Gets or sets the type of underline applied to the font. |RW |Underline|
|UnderlineColor |Color |Gets or sets the color of the underline applied to the font. |RW |UnderlineColor|
We hope this helps!