GuidePDF Operations

Extract Pages

This documentation provides an example of how to use the FileforgeClient to extract pages from a PDF.


Ensure you have the following:

  • An API key for Fileforge as an environment variable: process.env.FILEFORGE_API_KEY
  • Node.js and npm installed.
  • The Fileforge Client installed.


Make sure to set a timeout for the request

If you are extracting pages from a very large file, you may need to increase the timeout as shown below with the timeoutInSeconds parameter.

Extract the pages

1import { FileforgeClient } from "@fileforge/client";
2import * as fs from "fs";
4BETA TESTING - NOT YET AVAILABLE for more information

About the options and output

You can pass the following parameters to the extract method:

  • startPage: The index of the first page to extract. The index is one-based, so the first page is 1.
  • endPage: The index of the last page to extract (included). The index is one-based.

The extract method returns a .pdf file containing the extracted pages. The name of the output file is original file name suffixed with _extracted_startPage_endPage.