Skip to main content
This quickstart shows you how to upload a PDF containing one or more letters with pre-inserted addresses, and optionally split them into multiple UK postal mail items automatically using the Intelliprint API.
Time to complete: ~10 minutes

What you’ll build

You’ll learn how to:
  • Upload a PDF file with addresses already in it
  • Split one PDF into multiple letters automatically
  • Remove specific letters based on phrases
  • Send bulk mail from a single file

Prerequisites

1

API Key

Create an API key in your Intelliprint dashboard.
2

Prepare your PDF

You’ll need a PDF file with addresses already positioned where they should appear on each letter.
Download example files:

Scenario 1: Single Letter PDF

Send a single-page or multi-page letter from a PDF file.
import Intelliprint from 'intelliprint';
import fs from 'fs';

const ip = Intelliprint('your-api-key-here');

const printJob = await ip.prints.create({
  testmode: true,
  
  // Upload PDF file
  file: fs.createReadStream('./letter.pdf'),
  
  // No splitting needed for single letter
  splitting: {
    method: 'none'  // This is the default
  },
  
  confirmed: true
});

console.log('✓ Letter created from PDF');
console.log('Pages:', printJob.pages);
console.log('Sheets:', printJob.sheets);

Enable Double-Sided Printing

Save costs by printing on both sides of the paper:
const printJob = await ip.prints.create({
  testmode: true,
  file: fs.createReadStream('./letter.pdf'),
  
  // Enable double-sided printing
  printing: {
    double_sided: 'yes'
  },
  
  confirmed: true
});

console.log('Pages:', printJob.pages);      // e.g., 4 pages
console.log('Sheets:', printJob.sheets);    // e.g., 2 sheets (saves paper & cost!)
Cost savings: Double-sided printing reduces the number of physical sheets. For example, a 4-page PDF becomes 2 sheets instead of 4, reducing your costs.Learn more about double-sided printing →

Scenario 2: Split by Phrase

Split one PDF into multiple letters by searching for a phrase (like “Dear”) at the start of each letter.
Pro tip: Use white text on white background for the splitting phrase if you want to hide it from recipients!
import Intelliprint from 'intelliprint';
import fs from 'fs';

const ip = Intelliprint('your-api-key-here');

const printJob = await ip.prints.create({
  testmode: true,
  
  // Upload PDF with multiple letters
  file: fs.createReadStream('./multiple_letters.pdf'),
  
  // Split whenever "Dear" appears on a page
  splitting: {
    method: 'split_on_phrase',
    phrase: 'Dear'
  },
  
  confirmed: true
});

console.log('✓ PDF split into letters');
console.log('Total letters:', printJob.letters.length);
console.log('Total pages:', printJob.pages);
How it works: Intelliprint scans each page for the phrase. When found, it starts a new letter from that page. The phrase should appear once on the first page of each letter.

Scenario 3: Split by Page Count

Split based on a fixed number of pages per letter (e.g., every 2 pages = 1 letter).
const printJob = await ip.prints.create({
  testmode: true,
  file: fs.createReadStream('./letters.pdf'),
  
  // Every 2 pages becomes one letter
  splitting: {
    method: 'split_on_pages',
    pages: 2
  },
  
  confirmed: true
});

console.log('Split into', printJob.letters.length, 'letters');
// If PDF has 8 pages, this creates 4 letters (2 pages each)

Scenario 4: Remove Specific Letters

Remove letters containing a specific phrase (e.g., “EMAIL ONLY”).
const printJob = await ip.prints.create({
  testmode: true,
  file: fs.createReadStream('./letters.pdf'),
  
  // Split by phrase
  splitting: {
    method: 'split_on_phrase',
    phrase: 'Dear'
  },
  
  // Remove any letters containing "EMAIL ONLY"
  remove_letters: {
    with_phrase: 'EMAIL ONLY'
  },
  
  confirmed: true
});

console.log('Letters after filtering:', printJob.letters.length);
Use case: Your system exports a PDF with all customers, but some have opted for email-only. Add “EMAIL ONLY” text to those letters, and they’ll be automatically filtered out.

Using Remote URLs

Instead of uploading files, you can provide a URL:
const printJob = await ip.prints.create({
  testmode: true,
  
  // Provide URL instead of file upload
  file: {
    url: 'https://example.com/letters.pdf'
  },
  
  splitting: {
    method: 'split_on_phrase',
    phrase: 'Dear'
  },
  
  confirmed: true
});

Using Base64 Encoded Files

For programmatically generated PDFs, you can send Base64 encoded data:
const pdfBase64 = Buffer.from(pdfBytes).toString('base64');

const printJob = await ip.prints.create({
  testmode: true,
  
  file: {
    content: pdfBase64,
    name: 'letters.pdf'
  },
  
  splitting: {
    method: 'split_on_phrase',
    phrase: 'Dear'
  },
  
  confirmed: true
});

Splitting Methods Comparison

MethodWhen to UseParameters
noneSingle letter PDFNone (default)
split_on_phraseMultiple letters with a common phrasephrase - text to search for
split_on_pagesFixed page count per letterpages - pages per letter
mailing_listPDF template + recipient listmailing_list - list ID

Tips for Success

Make sure addresses in your PDF are positioned where they’ll show through the envelope window. Standard position is:
  • Left window: 20mm from left, 45mm from top
  • Right window: 90mm from left, 45mm from top
Learn about nudging addresses →
  • The phrase should appear exactly once on the first page of each letter
  • Phrases are case-sensitive
  • Use unique phrases like “SPLIT_HERE” to avoid false matches
  • White text on white background hides the phrase from recipients
  • PDF (recommended)
  • Microsoft Word (.docx)
  • RTF (.rtf)
  • Images (JPG, PNG) for single pages
  • Maximum file size: 50MB
  • Maximum pages: 1000 pages per print job
  • Large files may take longer to process

Next Steps