Add line after header and before footer in Microsoft Word Document

Hi Team,

We need to add line after header and before footer. How can we achieve that using Aspose.Words cloud api.

Regards,
Nipun Jain

@nipunjain1964

Please use SpaceBefore and SpaceAfter properties of following API:

POST /words/{name}/{nodePath}/paragraphs/{index}/format

Following is an example:

name = SampleDocument.docx
dto = { “SpaceBefore”: 30, “SpaceAfter”: 30 }
nodePath = sections/0/headersfooters/0
index = 0
destFileName = SampleDocument_Result.docx

Input Document: SampleDocument.docx
Output Document: SampleDocument_Result.docx

The complete list of properties is given below:

|Property Name |Type |Description |
|—|—|—|—|—|
|AddSpaceBetweenFarEastAndAlpha |bool |Gets or sets a flag indicating whether inter-character spacing is automatically adjusted between regions of Latin text and regions of East Asian text in the current paragraph. |RW |AddSpaceBetweenFarEastAndAlpha|
|AddSpaceBetweenFarEastAndDigit |bool |Gets or sets a flag indicating whether inter-character spacing is automatically adjusted between regions of numbers and regions of East Asian text in the current paragraph. |RW |AddSpaceBetweenFarEastAndDigit|
|Alignment |Aspose.Words.ParagraphAlignment |Gets or sets text alignment for the paragraph. |RW |Alignment|
|Bidi |bool |Gets or sets whether this is a right-to-left paragraph. |RW |Bidi|
|DropCapPosition |Aspose.Words.DropCapPosition |Gets or sets the position for a drop cap text. |RW |DropCapPosition|
|FirstLineIndent |double |Gets or sets the value (in points) for a first line or hanging indent. Use a positive value to set a first-line indent, and use a negative value to set a hanging indent. |RW |FirstLineIndent|
|KeepTogether |bool |True if all lines in the paragraph are to remain on the same page. |RW |KeepTogether|
|KeepWithNext |bool |True if the paragraph is to remains on the same page as the paragraph that follows it. |RW |KeepWithNext|
|LeftIndent |double |Gets or sets the value (in points) that represents the left indent for paragraph. |RW |LeftIndent|
|LineSpacing |double |Gets or sets the line spacing (in points) for the paragraph. |RW |LineSpacing|
|LineSpacingRule |Aspose.Words.LineSpacingRule |Gets or sets the line spacing for the paragraph. |RW |LineSpacingRule|
|LinesToDrop |int |Gets or sets the number of lines of the paragraph text used to calculate the drop cap height. |RW |LinesToDrop|
|NoSpaceBetweenParagraphsOfSameStyle |bool |When true, “SpaceBefore” and “SpaceAfter” will be ignored between the paragraphs of the same style. |RW |NoSpaceBetweenParagraphsOfSameStyle|
|OutlineLevel |Aspose.Words.OutlineLevel |Specifies the outline level of the paragraph in the document. |RW |OutlineLevel|
|PageBreakBefore |bool |True if a page break is forced before the paragraph. |RW |PageBreakBefore|
|RightIndent |bool |Gets or sets the value (in points) that represents the right indent for paragraph. |RW |RightIndent|
|SpaceAfter |double |Gets or sets the amount of spacing (in points) after the paragraph. |RW |SpaceAfter|
|SpaceAfterAuto |bool |True if the amount of spacing after the paragraph is set automatically. |RW |SpaceAfterAuto|
|SpaceBefore |double |Gets or sets the amount of spacing (in points) before the paragraph. |RW |SpaceBefore|
|SpaceBeforeAuto |bool |True if the amount of spacing before the paragraph is set automatically. |RW |SpaceBeforeAuto|
|StyleIdentifier |Aspose.Words.StyleIdentifier |Gets or sets the locale independent style identifier of the paragraph style applied to this formatting. |RW |StyleIdentifier|
|StyleName |string |Gets or sets the name of the paragraph style applied to this formatting. |RW |StyleName|
|SuppressAutoHyphens |bool |Specifies whether the current paragraph should be exempted from any hyphenation which is applied in the document settings. |RW |SuppressAutoHyphens|
|SuppressLineNumbers |bool |Specifies whether the current paragraph’s lines should be exempted from line numbering which is applied in the parent section. |RW |SuppressLineNumbers|
|WidowControl |bool |True if the first and last lines in the paragraph are to remain on the same page as the rest of the paragraph. |RW |WidowControl|

We hope this helps!

Hi team,

Thanks for the reply.

We want to add lines (with a color and a width) after header and before footer.

The same can be done using shape via Aspose.Words dll. How can we achieve the same using Aspose.Words cloud api.

Regards,
Nipun Jain

Hi team,

Can you look into this asap.

Regards,
Nipun Jain

@nipunjain1964

You can add line shape after the header and before footer using the following API:

PUT /words/{name}/{nodePath}/drawingObjects

Description of DrawingObject parameters is given below:

  1. Name: RelativeHorizontalPosition
    Description: Specifies where the distance to the image is measured from.
    Type: RelativeHorizontalPosition Enum | Aspose.Words for .NET

  2. Name: RelativeVerticalPosition
    Description: Specifies where the distance to the image is measured from.
    Type: https://reference.aspose.com/net/words/aspose.words.drawing/relativeverticalposition/

  3. Name: Left
    Description: Distance in points from the origin to the left side of the image.
    Type: double

  4. Name: Top
    Description: Distance in points from the origin to the top side of the image.
    Type: double

  5. Name: Width
    Description: Width of the drawing objects in points.
    Type: double

  6. Name: Height
    Description: Height of the drawing object in points.
    Type: double

  7. Name: WrapType
    Description: Specifies how to wrap text around the image.
    Type: WrapType Enum | Aspose.Words for .NET

Following is an API example:

name = SampleDocument_Result.docx
drawingObject = { “RelativeHorizontalPosition”: “Margin”, “Left”: 100, “RelativeVerticalPosition”: “Margin”, “Top”: 0, “Width”: 300, “Height”: 1, “WrapType”: “None” }
imageFile = line.png
nodePath = sections/0/headersfooters/0/paragraphs/0

Input Document: SampleDocument_Result.docx.zip
Output Document: SampleDocument_Output.docx.zip