Download PDF

Downloads a generated PDF (or spatial ZIP bundle) by its ID or direct URL. You can save it directly to your file system or return it as a raw Node.js memory Buffer.

cURL

curl -L "https://api.forkpdf.com/v1/pdfs/xxxxxxxx-2a51-7551-af33-b0af9cefe1e7/download" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-project-id: YOUR_PROJECT_ID" \
  -o document.pdf

Example Response

HTTP/2 200
content-type: application/pdf
content-disposition: attachment; filename="document.pdf"
content-length: 75285

The response body is the raw PDF (or spatial ZIP). -o writes it to disk; -L follows the storage redirect.

SDK

// 1. Download directly to a local directory
const fileResult = await client.download('pdf-uuid-here', { outputDir: './downloads' });
console.log(fileResult);
/*
{
  pdfFilePath: 'downloads/document.pdf'
}
*/

// 2. Download into memory as a Buffer
const bufferResult = await client.download('pdf-uuid-here');
console.log(bufferResult);
/*
{
  pdfBuffer: <Buffer 25 50 44 46 2d ... >,
  testResults: null
}
*/