Skip to main content

PDF Customization

Generate customized PDF documents for invoices, reports, and custom outputs.


PDF Generation Approaches

THREE APPROACHES TO PDF GENERATION
-------------------------------------------------------------------------------

1. ADVANCED PDF TEMPLATES (Built-in)
+-----------------------------------------------------------------------------+
| What: Template-based PDF customization |
| How: XML/FreeMarker templates in NetSuite UI |
| Best for: Transaction documents (invoices, POs, statements) |
| Requires: Template knowledge, XML/HTML |
+-----------------------------------------------------------------------------+

2. SUITELET PDF GENERATION (Script-Driven)
+-----------------------------------------------------------------------------+
| What: Generate PDFs programmatically via SuiteScript |
| How: N/render module creates PDFs from templates or HTML |
| Best for: Custom reports, user-triggered exports, dynamic documents |
| Requires: SuiteScript knowledge |
+-----------------------------------------------------------------------------+

3. BULK PDF (Map/Reduce)
+-----------------------------------------------------------------------------+
| What: High-volume batch PDF generation |
| How: Map/Reduce script processes thousands of records |
| Best for: Monthly statements, bulk invoices, mass document generation |
| Requires: SuiteScript, Map/Reduce pattern |
+-----------------------------------------------------------------------------+

Choosing the Right Approach

ScenarioRecommended Approach
Custom invoice layoutAdvanced PDF Template
Custom packing slipAdvanced PDF Template
Sales order formAdvanced PDF Template
Custom report from SuiteletSuitelet PDF Generation
User-triggered exportSuitelet PDF Generation
Print 1,000+ invoicesBulk PDF (Map/Reduce)
Monthly statement batchBulk PDF (Map/Reduce)

Quick Comparison

FEATURE COMPARISON
-------------------------------------------------------------------------------

Feature | Advanced PDF | Suitelet PDF | Bulk PDF
------------------------+-----------------+-----------------+----------------
Template Location | NetSuite UI | File Cabinet | File Cabinet
------------------------+-----------------+-----------------+----------------
Coding Required | XML/HTML | SuiteScript | SuiteScript
------------------------+-----------------+-----------------+----------------
Volume | Single record | Low-Medium | High (1000+)
------------------------+-----------------+-----------------+----------------
Trigger | Print button | Script/Suitelet | Scheduled
------------------------+-----------------+-----------------+----------------
Best Use Case | Transactions | Reports/Forms | Bulk exports

Architecture Overview

PDF GENERATION FLOW
-------------------------------------------------------------------------------

ADVANCED PDF TEMPLATE:
+-----------------------------------------------------------------------------+
| Transaction Record --> Template Engine --> PDF Output |
| (Invoice) (BFO/FreeMarker) (Download/Email) |
+-----------------------------------------------------------------------------+

SUITELET PDF:
+-----------------------------------------------------------------------------+
| Suitelet Script --> N/render Module --> PDF File --> Response |
| (User Request) (mergeEmail/xmlToPdf) (File Cabinet) (Download) |
+-----------------------------------------------------------------------------+

BULK PDF (MAP/REDUCE):
+-----------------------------------------------------------------------------+
| Scheduled/On-Demand --> Map: Load Records --> Reduce: Create PDFs |
| (Transaction List) (Save to Cabinet/Email) |
+-----------------------------------------------------------------------------+

Template Basics

All PDF approaches share common concepts:

1. Document Structure

<?xml version="1.0"?>
<!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
<style type="text/css">
/* CSS styles here */
</style>
</head>
<body size="Letter">
<!-- Content here -->
</body>
</pdf>

2. Data Access

Accessing Record Data:
${record.field} - Standard field
${record.custbody_xxx} - Custom body field
${item.custcol_xxx} - Custom column field (in loop)

Accessing Related Records:
${record.field@subfield} - Field from linked record
${record.recmachfield} - Child records (Record is Parent)

3. Output Options

OUTPUT OPTIONS
-------------------------------------------------------------------------------

DISPLAY IN BROWSER:
+-----------------------------------------------------------------------------+
| context.response.writeFile({ |
| file: pdfFile, |
| isInline: true // Display in browser |
| }); |
+-----------------------------------------------------------------------------+

FORCE DOWNLOAD:
+-----------------------------------------------------------------------------+
| context.response.writeFile({ |
| file: pdfFile, |
| isInline: false // Force download |
| }); |
+-----------------------------------------------------------------------------+

SAVE TO FILE CABINET:
+-----------------------------------------------------------------------------+
| var pdfFile = render.xmlToPdf({ xmlString: pdfContent }); |
| pdfFile.folder = 123; // File Cabinet folder ID |
| pdfFile.name = 'Invoice-' + invoiceId + '.pdf'; |
| var fileId = pdfFile.save(); |
| |
| // Optionally attach to record |
| record.attach({ |
| record: {type: 'file', id: fileId}, |
| to: {type: 'invoice', id: invoiceId} |
| }); |
+-----------------------------------------------------------------------------+

EMAIL ATTACHMENT:
+-----------------------------------------------------------------------------+
| email.send({ |
| author: employeeId, |
| recipients: [customerId], |
| subject: 'Your Invoice', |
| body: 'Please find attached...', |
| attachments: [pdfFile] |
| }); |
+-----------------------------------------------------------------------------+

PDF Topics

TopicDescription
Advanced PDF Templates →Built-in template customization with step-by-step tutorials
Suitelet PDF Generation →Script-driven PDF creation
Bulk PDF Generation →High-volume batch processing

Common Use Cases

ADVANCED PDF TEMPLATES:
+-----------------------------------------------------------------------------+
| - Custom branded invoices |
| - Purchase orders with company logo |
| - Packing slips with warehouse instructions |
| - Statements with payment history |
| - Sales orders with terms |
| - Return authorizations |
+-----------------------------------------------------------------------------+

SUITELET PDF:
+-----------------------------------------------------------------------------+
| - Custom reports (sales summaries, inventory reports) |
| - Employee documents (offer letters, contracts) |
| - User-requested exports |
| - Dashboard PDF exports |
| - Certificate generation |
+-----------------------------------------------------------------------------+

BULK PDF (MAP/REDUCE):
+-----------------------------------------------------------------------------+
| - Monthly customer statements (1000+ customers) |
| - Mass invoice printing |
| - End-of-year tax documents |
| - Archival document generation |
| - Scheduled report distribution |
+-----------------------------------------------------------------------------+

Getting Started Checklist

StepAdvanced PDFSuitelet PDFBulk PDF
1Navigate to TemplatesCreate Suitelet scriptCreate Map/Reduce script
2Create new templateDefine HTML/XML templateQuery records in getInputData
3Add XML/FreeMarker codeUse N/render moduleGenerate PDFs in map/reduce
4Link to transaction formDeploy SuiteletDeploy script + schedule
5Test with Print buttonTest via URLMonitor script execution

References