Delete PDF Pages API
Remove selected pages or ranges from PDF files with password support and automatic blank page deletion for clean output.
PDFs collect pages you don't want: terms-and-conditions boilerplate in invoices, blank pages from double-sided scanning, cover sheets from fax gateways, or sections that simply don't belong in the final document. Opening each file in an editor does not scale - if your application handles documents, you need to delete PDF pages programmatically.
This guide shows how to do it with the Delete PDF Pages API: removing single pages and page ranges, detecting and dropping blank pages automatically, and ready-to-run code in C#, Python, Node.js, PHP, and Java.
Post your file and list the pages to remove:
curl -X POST https://v2.convertapi.com/convert/pdf/to/delete-pages \
-H "Authorization: Bearer api_token" \
-F "File=@/path/to/document.pdf" \
-F "PageRange=1,5,7-10"
The response contains the PDF with those pages gone. No PDF libraries to install, no page-tree internals to learn.
The PageRange parameter accepts single pages, ranges, and any combination of both, separated by commas:
5 - delete one page1-10 - delete a range1,5,7-10,13-15 - mix individual pages and ranges in one callPage numbers are 1-based, and documents with up to 20,000 pages are supported, so batch-processing large archives is not a problem.
Blank pages usually sneak in through double-sided scanning (every one-sided original leaves an empty back side) or from print-to-PDF drivers padding documents. Hunting their page numbers manually defeats the point of automation, so the API can detect and remove them for you:
curl -X POST https://v2.convertapi.com/convert/pdf/to/delete-pages \
-H "Authorization: Bearer api_token" \
-F "File=@/path/to/scanned-document.pdf" \
-F "DeleteBlankPages=true"
Set DeleteBlankPages to true and every blank page is dropped automatically - no page numbers needed. It also works alongside PageRange, so you can strip a cover sheet and clean up blank scan pages in a single call.
Install the ConvertAPI .NET SDK from NuGet:
dotnet add package ConvertApiusing ConvertApiDotNet;
var convertApi = new ConvertApi("api_token");
var result = await convertApi.ConvertAsync("pdf", "delete-pages",
new ConvertApiFileParam(@"C:\docs\report.pdf"),
new ConvertApiParam("PageRange", "1,5,7-10")
);
await result.SaveFilesAsync(@"C:\docs\trimmed");pip install convertapiimport convertapi
convertapi.api_credentials = 'api_token'
convertapi.convert('delete-pages', {
'File': '/path/to/scanned-document.pdf',
'DeleteBlankPages': True
}, from_format = 'pdf').save_files('/path/to/cleaned')npm install convertapiconst convertapi = require('convertapi')('api_token');
convertapi.convert('delete-pages', {
File: './files/report.pdf',
PageRange: '2,5-8'
}, 'pdf').then(function(result) {
return result.saveFiles('./files/trimmed');
});composer require convertapi/convertapi-phpConvertApi::setApiCredentials('api_token');
$result = ConvertApi::convert('delete-pages', [
'File' => '/path/to/scanned-document.pdf',
'DeleteBlankPages' => 'true',
], 'pdf'
);
$result->saveFiles('/path/to/cleaned');<dependency>
<groupId>com.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<version>2.10</version>
</dependency>Config.setDefaultApiCredentials("api_token");
ConvertApi.convert("pdf", "delete-pages",
new Param("File", Paths.get("/path/to/report.pdf")),
new Param("PageRange", "1,5,7-10")
).get().saveFilesSync(Paths.get("/path/to/trimmed"));Deleting pages is often one step in a longer pipeline. The same API family covers the rest, so you can chain actions without downloading intermediate files:
The full toolbox lives on the PDF Tools REST API page.
Pass DeleteBlankPages=true to the delete-pages endpoint. The API detects blank pages - typical leftovers from double-sided scanning - and removes them without you specifying any page numbers.
Yes. PageRange takes any comma-separated combination of pages and ranges, like 1,5,7-10,13-15, so one request handles even complex cleanups.
Yes. Pass the document password in the Password parameter and the API will open the file, delete the pages, and return the result.
Yes - removing pages removes their content. If size is the main goal, pair it with the compress endpoint; see our guide on compressing PDF files programmatically.
Deleting PDF pages programmatically is a single HTTP call: list the pages in PageRange, or let DeleteBlankPages clean up scans automatically. Try it in the browser on the Delete PDF Pages API page - the interactive demo generates a working snippet for your language while you tweak the parameters.