How to Add HTML text in Word Document Headers Footers using Aspose.Words Cloud API

We’re trying to generate HTML --> word document with headers and footers.
How can we add/ edit the headers footers so they take the content & formatting from HTML

e.g. we would like to add the following in footer

<p style="text-align: left;">Footer Text, <strong>Postcode</strong> | <span style="color: #ff9900;">More Footer Text</span></p>
<p style="text-align: center;">&copy; copyright information</p>
<p style="text-align: right;"><span style="color: #0000ff;">Page | {pagenumber}</span></p>

Thanks

@RBIEGTechTeam

Please share your input HTML and expected Word Document here, you may convert HTML to Word Document using Microsoft Word. We will look into your requirement and will guide you accordingly.

Hi

Please find attached the sample HTML file and word file.
Based on the solution you provide, we can have the content and header footers in the same HTML file or we can have them in seprate HTML files.

Thanks

sample HTML and word document.zip (132.7 KB)

@RBIEGTechTeam

Thanks for sharing additional information. Please note Aspose.Words mimics MS Word behavior, Aspose.Words does not honor html header/footer content. So we need to add header/footer separately in Word Document. Aspose.Words Cloud API supports to add Header/Footer in Word document and later you can add Text/Image in the Header/Footer. Please check following API for details.

Insert Header/Footer
Add Text
Add DrawingObjects

However, currently Aspose.Words Cloud API does not support to add HTML text in Header/Footer. We have logged a ticket WORDSCLOUD-711 for the requirement. We will notify you as soon as it is resolved.

Meanwhile you may consider to update text formatting.

Here is an example:
name = SampleDocument.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

Following is the description of Font object attributes:

Property Name Type Description
AllCaps bool True if the font is formatted as all capital letters.
Bidi bool Specifies whether the contents of this run shall have right-to-left characteristics.
Bold bool True if the font is formatted as bold.
BoldBi bool True if the right-to-left text is formatted as bold.
Border Border Border object that specifies border for the font.
Color Color Gets or sets the color of the font.
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.
DoubleStrikeThrough bool True if the font is formatted as double strikethrough text.
Emboss bool True if the font is formatted as embossed.
Engrave bool True if the font is formatted as engraved.
Hidden bool True if the font is formatted as hidden text.
HighlightColor Color Gets or sets the highlight (marker) color.
Italic bool True if the font is formatted as italic.
ItalicBi bool True if the right-to-left text is formatted as italic.
Kerning double Gets or sets the font size at which kerning starts.
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
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
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
Name string Gets or sets the name of the font.
NameAscii bool Returns or sets the font used for Latin text (characters with character codes from 0 (zero) through 127).
NameBi bool TReturns or sets the name of the font in a right-to-left language document.
NameFarEast bool Returns or sets an East Asian font name.
NameOther bool Returns or sets the font used for characters with character codes from 128 through 255.
NoProofing bool True when the formatted characters are not to be spell checked.
Outline bool True if the font is formatted as 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.
Scaling int Gets or sets character width scaling in percent.
Shadow bool True if the font is formatted as shadowed.
Size double Gets or sets the font size in points.
SizeBi double Gets or sets the font size in points used in a right-to-left document.
SmallCaps bool True if the font is formatted as small capital letters.
Spacing double Returns or sets the spacing (in points) between characters.
StrikeThrough bool True if the font is formatted as strikethrough text.
StyleIdentifier StyleIdentifier Gets or sets the locale independent style identifier of the character style applied to this formatting.
StyleName string Gets or sets the name of the character style applied to this formatting.
Subscript bool True if the font is formatted as subscript.
Superscript bool True if the font is formatted as superscript.
TextEffect TextEffect Gets or sets the font animation effect.
Underline Underline Gets or sets the type of underline applied to the font.
UnderlineColor Color Gets or sets the color of the underline applied to the font.

Hi Tilal,

Thanks fo the update, do we have an expected release date for this feature

Thanks,
Abhishek

@RBIEGTechTeam

I am afraid we cannot share any ETA at the moment, as the issue is still pending for investigation in the queue. As soon as the issue analysis is completed, then we will be in a good position to share any ETA with you.

Thanks for your patience and cooperation.

WORDSCLOUD-711 is marked as closed, does this mean the functionality to add HTML to header/footer is now available or the issue has been closed as it will not be resolved?

@RBIEGTechTeam

Thanks for your inquiry. Yes, your reported issue is resolved and its fix will be available in upcoming release 19.10. We will share the fix details, as soon as the new release is published.

@RBIEGTechTeam

Thanks for your patience. We have resolved your above reported issue in latest release, 19.10. You can add HTML text using Range API. We added “TextType” property to ReplaceRange model.
Example request for replace with html:

{

"Text": "<b>Replaced Text</b>",

"TextType": "Html"

}

Supported TextType: Text, Html