PDF Customization
Generate customized PDF documents for invoices, reports, and custom outputs.
PDF Generation Approaches
PDF GENERATION METHODS
═══════════════════════════════════════════════════════════════════════════════
┌─────────────────────────────────────────────────────────────────────────────┐
│ 1. ADVANCED PDF TEMPLATES │
│ ───────────────────────── │
│ • Built-in NetSuite feature │
│ • BFO (Big Faceless Organization) template engine │
│ • Best for: Transaction documents (invoices, POs, statements) │
│ • Requires: Template knowledge, XML/HTML │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ 2. SUITELET PDF GENERATION │
│ ────────────────────────── │
│ • Script-driven PDF creation │
│ • Use N/render module │
│ • Best for: Custom reports, on-demand PDFs, user-triggered exports │
│ • Requires: SuiteScript knowledge │
└─────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ 3. BULK PDF GENERATION (MAP/REDUCE) │
│ ─────────────────────────────────── │
│ • High-volume batch processing │
│ • Handles thousands of documents │
│ • Output: Concatenated PDF or ZIP archive │
│ • Best for: Mass printing, bulk exports, scheduled reports │
│ • Requires: Map/Reduce script knowledge │
└─────────────────────────────────────────────────────────────────────────────┘
Choosing the Right Approach
| Scenario | Recommended Approach |
|---|---|
| Custom invoice layout | Advanced PDF Template |
| Custom packing slip | Advanced PDF Template |
| Sales order form | Advanced PDF Template |
| Custom report from Suitelet | Suitelet PDF Generation |
| User-triggered export | Suitelet PDF Generation |
| Print 1,000+ invoices | Bulk PDF (Map/Reduce) |
| Monthly statement batch | Bulk PDF (Map/Reduce) |
| End-of-month report package | Bulk PDF (Map/Reduce) |
Quick Comparison
APPROACH COMPARISON
═══════════════════════════════════════════════════════════════════════════════
│ Advanced PDF │ Suitelet │ Bulk (M/R)
────────────────────────┼───────────────┼───────────────┼────────────────
Complexity │ Low-Medium │ Medium │ High
────────────────────────┼───────────────┼───────────────┼────────────────
Coding Required │ XML/HTML │ SuiteScript │ SuiteScript
────────────────────────┼───────────────┼───────────────┼────────────────
Volume │ Single docs │ Single/Few │ 1000s
────────────────────────┼───────────────┼───────────────┼────────────────
Custom Data │ Record data │ Any data │ Any data
────────────────────────┼───────────────┼───────────────┼────────────────
Scheduling │ No │ Manual │ Yes
────────────────────────┼───────────────┼───────────────┼────────────────
Output │ Single PDF │ Single PDF │ Merged/ZIP
────────────────────────┼───────────────┼───────────────┼────────────────
Best Use Case │ Transactions │ Reports/Forms │ Bulk exports
Architecture Overview
PDF GENERATION FLOW
═══════════════════════════════════════════════════════════════════════════════
ADVANCED PDF TEMPLATES:
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────────┐ ┌───────────┐ ┌──────────┐ │
│ │ Record │ → │ PDF Template │ → │ BFO Engine│ → │ PDF │ │
│ │ (Invoice)│ │ (XML/HTML) │ │ │ │ Output │ │
│ └──────────┘ └──────────────┘ └───────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
SUITELET PDF:
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────────┐ ┌───────────┐ ┌──────────┐ │
│ │ Suitelet │ → │ N/render │ → │ Template │ → │ PDF │ │
│ │ Request │ │ Module │ │ or XML │ │ Output │ │
│ └──────────┘ └──────────────┘ └───────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
BULK PDF (MAP/REDUCE):
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ ┌──────────┐ ┌──────────────┐ ┌───────────┐ ┌──────────┐ │
│ │ Search │ → │ Map: Create │ → │ Reduce: │ → │ Merged │ │
│ │ (Records)│ │ Individual │ │ Combine │ │ PDF/ZIP │ │
│ │ │ │ PDFs │ │ PDFs │ │ │ │
│ └──────────┘ └──────────────┘ └───────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
PDF Module Overview
N/render Module
/**
* Core PDF generation module
*/
define(['N/render'], function(render) {
// Render record to PDF using template
var pdf = render.transaction({
entityId: recordId,
printMode: render.PrintMode.PDF
});
// Render custom XML to PDF
var xmlPdf = render.xmlToPdf({
xmlString: customXml
});
// Create PDF from template
var templatePdf = render.create();
templatePdf.templateContent = templateXml;
templatePdf.addRecord('record', myRecord);
var pdfFile = templatePdf.renderAsPdf();
});
PDF Output Options
PDF OUTPUT HANDLING
═══════════════════════════════════════════════════════════════════════════════
RETURN TO BROWSER (Suitelet):
┌─────────────────────────────────────────────────────────────────────────────┐
│ context.response.writeFile({ │
│ file: pdfFile, │
│ isInline: true // Display in browser │
│ }); │
└─────────────────────────────────────────────────────────────────────────────┘
DOWNLOAD:
┌─────────────────────────────────────────────────────────────────────────────┐
│ context.response.writeFile({ │
│ file: pdfFile, │
│ isInline: false // Force download │
│ }); │
└─────────────────────────────────────────────────────────────────────────────┘
SAVE TO FILE CABINET:
┌─────────────────────────────────────────────────────────────────────────────┐
│ pdfFile.folder = folderId; │
│ pdfFile.name = 'Invoice_123.pdf'; │
│ var fileId = pdfFile.save(); │
└─────────────────────────────────────────────────────────────────────────────┘
ATTACH TO RECORD:
┌─────────────────────────────────────────────────────────────────────────────┐
│ record.attach({ │
│ record: {type: 'file', id: fileId}, │
│ to: {type: 'invoice', id: invoiceId} │
│ }); │
└─────────────────────────────────────────────────────────────────────────────┘
EMAIL AS ATTACHMENT:
┌─────────────────────────────────────────────────────────────────────────────┐
│ email.send({ │
│ author: -5, │
│ recipients: 'customer@email.com', │
│ subject: 'Your Invoice', │
│ body: 'Please find attached invoice.', │
│ attachments: [pdfFile] │
│ }); │
└─────────────────────────────────────────────────────────────────────────────┘
PDF Topics
| Topic | Description |
|---|---|
| Advanced PDF Templates → | Built-in template customization |
| Suitelet PDF Generation → | Script-driven PDF creation |
| Bulk PDF Generation → | High-volume batch processing |
Common Use Cases
PDF USE CASES BY APPROACH
═══════════════════════════════════════════════════════════════════════════════
ADVANCED PDF TEMPLATES:
┌─────────────────────────────────────────────────────────────────────────────┐
│ • Custom branded invoices │
│ • Purchase orders with company logo │
│ • Packing slips with barcodes │
│ • Customer statements │
│ • Sales orders with terms │
│ • Return authorizations │
└─────────────────────────────────────────────────────────────────────────────┘
SUITELET PDF:
┌─────────────────────────────────────────────────────────────────────────────┐
│ • Custom inventory reports │
│ • Sales commission reports │
│ • Custom certificates/letters │
│ • Dynamic data exports │
│ • User-triggered downloads │
│ • Dashboard export buttons │
└─────────────────────────────────────────────────────────────────────────────┘
BULK PDF (MAP/REDUCE):
┌─────────────────────────────────────────────────────────────────────────────┐
│ • Month-end invoice batch │
│ • Quarterly statement mailing │
│ • Annual 1099 generation │
│ • Bulk packing slip printing │
│ • Report packages for auditors │
│ • Mass purchase order distribution │
└─────────────────────────────────────────────────────────────────────────────┘
Next Steps
| Goal | Go To |
|---|---|
| Customize transaction PDFs | Advanced PDF Templates → |
| Build custom PDF Suitelet | Suitelet PDF Generation → |
| Generate PDFs in bulk | Bulk PDF Generation → |