Add Text Header Footer - Excel API
PDF4me Add Text Header Footer enables you to add customizable text headers and footers to Excel documents with comprehensive formatting control. This API service processes Excel files and adds text to header or footer sections with font styling (family, size, color), transparency levels, rotation angles, and orientation options (horizontal, vertical, diagonal, upside-down). The API receives Excel document content through REST API calls, utilizing Base64 encoding for secure transmission. This solution is ideal for document branding, page numbers, dates, and professional presentation workflows.
Authenticating Your API Request
Include your API key in the request to authenticate with the PDF4me REST API.
Key Features
- Custom Text Content: Add any text as header or footer on Excel documents
- Font Customization: Control font family, size, color, and specific font names
- Transparency Control: Set semi-transparent (50% opacity) or fully opaque (100%) text
- Rotation & Orientation: Apply rotation angles or preset orientations (horizontal, vertical, diagonal, upside-down)
- Culture Support: Specify culture codes for proper text rendering and formatting
REST API Endpoint
- Method: POST
- Endpoint:
office/ApiV2Excel/ExcelAddTextHeaderFooter
REST API Parameters
Important: Parameters marked with an asterisk (*) are required. All requests use document, docContent, and one action object. Operation-specific parameters are properties of addTextHeaderFooterToExcelAction.
Required Parameters (root level)
| Parameter | Type | Description | Example |
|---|---|---|---|
| document* | Object | Document reference. Must contain Name (string) — Excel file name with .xlsx or .xls extension | { "Name": "data.xlsx" } |
| docContent* | String (Base64) | Excel document content encoded in Base64 | UEsDBBQABgAIAAAA... |
| addTextHeaderFooterToExcelAction* | Object | Action configuration. Must contain at least watermarkText (string) — text to display as header or footer | See Payload example below |
Optional Parameters (inside addTextHeaderFooterToExcelAction)
| Parameter | Type | Description | Example |
|---|---|---|---|
| fontFamily | String | Font family name (e.g., Arial, Times New Roman). Default: Arial | Arial |
| fontSize | Number | Font size in points (8–72). Default: 72 | 12 |
| fontColor | String | Hex color code or color name. Default: black | #0000FF |
| semiTransparent | Boolean | true = 50% opacity, false = 100% (default) | false |
| rotation | Number | Rotation angle in degrees (0–360). Default: 0 | 45 |
| fontName | String | Specific font name (overrides fontFamily) | Arial Bold |
| orientation | String | Horizontal, Vertical, Diagonal, or Upside-Down. Takes priority over rotation | Horizontal |
| cultureName | String | Culture code for text rendering (e.g., "en-US", "de-DE") | en-US |
Output
The API returns the Excel document as a Base64-encoded string in JSON format.
- Success Response
- Error Responses
Status Code: 200 OK
Response Body:
{
"document": "UEsDBBQABgAIAAAA...",
"fileName": "data.xlsx",
"success": true,
"errorMessage": null
}
400 Bad Request – Invalid parameters, missing required fields, invalid Base64 or document. 401 Unauthorized – Invalid or missing API key. 500 Internal Server Error – Server-side processing error.
Request Example
Header
Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY
Payload (Basic)
{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"addTextHeaderFooterToExcelAction": {
"watermarkText": "Confidential Report 2024"
}
}
Payload (With optional formatting)
{
"document": { "Name": "data.xlsx" },
"docContent": "UEsDBBQABgAIAAAA...",
"addTextHeaderFooterToExcelAction": {
"watermarkText": "Confidential Report 2024",
"fontFamily": "Arial",
"fontSize": 12,
"fontColor": "#0000FF",
"orientation": "Horizontal"
}
}
Code Samples
- GitHub