Get a document's page-by-page structured content into your application. In this guide, a short script uploads the statement and returns its recovered pages. You'll display the result in your terminal to inspect what your workflow will receive.
You'll need Node.js 24 and a Pagelet workspace. If you haven't created a workspace yet, follow the portal setup.
Create an API key
In the portal, open API Keys and select Create key. Give the key a name. For this example, select: Create uploads, Read job status, and Read results.
Select Create key and copy the key. The portal shows the full key only once.
Set up the example
Create a folder and install the SDK:
mkdir statement-example
cd statement-example
npm init -y
npm install @pagelet-ai/sdkDownload the sample statement into this folder as statement.pdf. To use your own document, replace the file path in the example below.
Create a .env file in the same folder, replacing your_api_key with your key:
PAGELET_API_KEY=your_api_keyKeep .env out of version control. Use the SDK in your backend or local scripts; don't put this key in browser code.
Extract the content
Save this as extract.mjs:
import { Pagelet } from "@pagelet-ai/sdk"
const client = new Pagelet()
const result = await client.documents.create({ file: "statement.pdf" })
for (const page of result.pages) {
console.log(page.page_number, page.markdown)
}Run it:
node --env-file=.env extract.mjsNode loads your .env file, and the client reads PAGELET_API_KEY automatically.
documents.create uploads the file and waits for its result. Your terminal then shows the extracted content from each page, in document order. You can inspect the returned content before passing it into the next step of your workflow.
Understand the response
documents.create returns the document and its recovered pages. This example shows a short Markdown excerpt from one page; IDs are examples.
{
"job": {
"id": "job_00000000000000000000000001",
"status": "completed"
},
"document": {
"id": "doc_00000000000000000000000001",
"filename": "statement.pdf",
"media_type": "application/pdf",
"page_count": 4,
"content_status": "available",
"confidence_score": 90
},
"pages": [
{
"page_number": 1,
"markdown": "# ALDER COAST\n\n**Your checking statement**\n\nSeptember 1, 2026 - September 30, 2026\n\n## About this statement\n\nYour activity appears in posting order on the following pages. Debit and credit columns separate money leaving the account from money received. The running balance reflects each posted transaction.",
"confidence_score": 90,
"warnings": []
}
],
"warnings": []
}document.ididentifies the document for later reads and searches.pagescontains the recovered content in source order. Each page has apage_numberandmarkdown.jobidentifies the processing request and its final status.warningsidentifies content that needs attention. Individual pages can also have warnings.
The complete result includes all four pages. Read results explains page access, confidence estimates, and missing content.
Use the result
Each item in result.pages contains a page's Markdown and its source page number. Keep them together so your application or AI agent can refer back to the original page.
Save result.document.id with your application's record. Use documents.result to retrieve the result later, documents.page to read one page, or Search to find a passage. You don't need to upload the file again.
For background work, jobs.create returns after submission. Your application can collect the result later or receive a webhook when processing finishes.
Check for missing content
Check result.warnings and each page's warnings before using the content. A page's markdown is null when extraction failed and an empty string when no text was found. Preserve that distinction so a missing page doesn't appear to be blank.