Skip to main content

Delete Pages from Word - Page Management API

PDF4me Delete Pages from Word enables you to remove specific pages or page ranges from Word documents with flexible page selection options. This API service processes Word files and deletes pages using range-based deletion (start page to end page), specific page number deletion (comma-separated lists), and combined deletion patterns. The API receives Word document content through REST API calls, utilizing Base64 encoding for secure transmission. With support for full control over page selection, document optimization, and content cleanup, this solution is ideal for document refinement, content management, and document preparation workflows.

Authenticating Your API Request

To access the PDF4me REST API, every request must include proper authentication credentials. Authentication ensures secure communication and validates your identity as an authorized user of the REST API.

Key Features

  • Flexible Page Selection: Delete pages by range, specific numbers, or combination of both
  • Range-Based Deletion: Remove consecutive pages from start page to end page
  • Specific Page Deletion: Remove individual pages using comma-separated page numbers
  • Document Optimization: Clean up documents by removing unwanted content
  • Format Preservation: Maintain original document formatting and structure
  • Metadata Preservation: Keep document properties and custom metadata
  • Validation: Automatic page number validation and error handling
  • Culture Support: Locale-specific document processing

REST API Endpoint

The PDF4me REST API uses standard HTTP methods to interact with resources. All page deletion operations are performed through a single endpoint:

  • Method: POST
  • Endpoint: office/ApiV2Word/DeletePages

REST API Parameters

Complete list of parameters for the Delete Pages from Word REST API. Parameters are organized by category for better understanding and implementation.

Important: Parameters marked with an asterisk (*) are required. At least one page deletion parameter (startPage, endPage, or pageNumbers) must be provided.

Required Parameters

ParameterTypeDescriptionExample
document*ObjectDocument reference. Must contain Name (string) — Word file name with .docx extension{ "Name": "document.docx" }
docContent*Base64Word document content encoded in Base64UEsDBBQABgAIAAAA...

Optional Parameters (At least one required for page deletion)

ParameterTypeDescriptionExample
startPageIntegerStart page number (1-based index). Page number to begin deleting from. Must be ≥ 1 and ≤ document page count. If only startPage provided, deletes from this page to end of document. Cannot be greater than endPage2
endPageIntegerEnd page number (1-based index). Page number to stop deleting at. Must be ≥ startPage and ≤ document page count. Range is inclusive (both start and end pages deleted). Can be combined with pageNumbers for complex deletion patterns5
pageNumbersStringComma-separated list of specific page numbers to delete. Format: "1,3,4" or "1-3,5,7-9". Can be used alone or combined with startPage/endPage. Invalid page numbers are silently ignored. Example: "2,4,6,8" deletes pages 2, 4, 6, and 8"2,4,6"
cultureNameStringCulture code for document processing (e.g., "en-US", "de-DE", "fr-FR"). Default: null (no culture-specific processing). Affects document language and formattingen-US

Page Deletion Modes

The API supports multiple page deletion modes:

  1. Range Deletion: Use startPage and endPage to delete consecutive pages
  2. Specific Page Deletion: Use pageNumbers to delete individual pages
  3. Combined Deletion: Use both range and specific page parameters together
  4. Delete to End: Use only startPage to delete from that page to document end

Note: All page numbers are 1-based (first page = 1, not 0). Page numbers are automatically validated against document page count.

Output

The PDF4me Delete Pages from Word REST API returns different responses based on the processing mode. The API returns the Word document as a Base64-encoded string in JSON format, not as binary data.

Synchronous Processing (Default)

The API processes the request and returns:

Status Code: 200 OK

Content-Type: application/json

Response Body:

{
"document": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"fileName": "document.docx",
"success": true,
"errorMessage": null
}

Response Fields:

  • document (string): The Word document with specified pages deleted, encoded as Base64 string
  • fileName (string): The output Word file name
  • success (boolean): Indicates whether the request succeeded
  • errorMessage (string or null): Error details when success is false

How to Use:

  1. Extract the document field from the JSON response (Base64)
  2. Decode the Base64 string to get the binary Word document data
  3. Save or process the Word file as needed

Example (JavaScript):

const response = await fetch(url, options);
const data = await response.json();
const wordBytes = atob(data.document); // Decode Base64
// Save or process wordBytes

Page Deletion Examples

Understanding different page deletion patterns:

Document PagesstartPageendPagepageNumbersResult
1,2,3,4,524-Keeps: 1,5
1,2,3,4,53--Keeps: 1,2
1,2,3,4,5--"2,4"Keeps: 1,3,5
1,2,3,4,523"5"Keeps: 1,4

Request Example

Content-Type: application/json
Authorization: Basic YOUR_BASE64_ENCODED_API_KEY

Note:

  • Get your API key from the PDF4me Dashboard
  • The API key must be Base64 encoded and prefixed with "Basic " in the Authorization header
  • Example: If your API key is abc123, encode it to Base64 and use Authorization: Basic YWJjMTIz

Payload

Basic Example (Range Deletion):

{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"startPage": 2,
"endPage": 4
}

Specific Pages Example:

{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"pageNumbers": "2,4,6,8"
}

Advanced Example (Combined Deletion):

{
"document": { "Name": "document.docx" },
"docContent": "UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC...",
"startPage": 2,
"endPage": 5,
"pageNumbers": "7,9",
"cultureName": "en-US"
}

Code Samples

The PDF4me Delete Pages from Word REST API provides code samples in multiple programming languages. Choose the language that best fits your development environment:

C# (CSharp) Sample

Complete C# implementation for deleting pages from Word documents:

Industry Use Cases & Applications

Legal & Professional Services Use Cases

  • Contract Cleanup: Remove signature pages and appendices from contract copies
  • Legal Document Preparation: Delete confidential pages before client distribution
  • Court Filing Optimization: Remove unnecessary pages to meet filing requirements
  • Client Document Versions: Create clean versions by removing internal notes

Get Help