NetSuite Automatic Printing: Send Invoices by API
Automatically send NetSuite invoice PDFs to physical printers with SuiteScript and PrintScaler. Follow a practical setup covering secure credentials, scheduled execution, and reliable retries.
By the PrintScaler team · · 10 min read
NetSuite automatic printing requires two steps: generate the transaction PDF in NetSuite, then deliver it to a service that can reach the physical printer. A SuiteScript scheduled script can render an invoice and submit it to PrintScaler, whose local agent handles printing without a browser dialog. This guide builds that workflow and explains how to make it safe for production.
What NetSuite automatic printing actually needs
Generating a PDF and printing it are different operations. NetSuite can produce transaction documents, but a cloud script does not automatically have access to the USB printer beside your accounting desk.
A working integration needs three components:
- A business trigger: the event that makes an invoice eligible for printing.
- A document renderer: SuiteScript generates the invoice PDF using your NetSuite transaction configuration.
- A delivery path: a cloud printing service passes that document to the correct physical printer.
PrintScaler provides the delivery path through an API and a small agent installed near the printer. This is a custom SuiteScript integration, not a claim of a built-in NetSuite connector or a one-click marketplace installation.
The example below prints an existing invoice by internal ID. It does not create invoices, change approval status, or replace your accounting controls.
Choose the print trigger before writing code
“Print every new invoice” sounds straightforward, but it leaves several important questions unanswered. Should an unapproved invoice print? Should an edited invoice print again? What happens when a CSV import creates hundreds of transactions?
Define the business rule first:
| Business event | Suggested behavior |
|---|---|
| Invoice created but not ready for release | Do not enqueue a print request |
| Invoice becomes eligible under your approval process | Create one original print request |
| Customer address changes afterward | Require an explicit decision about reprinting |
| Employee requests another copy | Create a separate, auditable reprint request |
| Printer computer is temporarily offline | Keep the existing job rather than submitting duplicates |
For production, separate transaction processing from printing. A user event script or another business process can create a custom queue record; a scheduled or Map/Reduce script can process that queue afterward.
That queue is something you implement in NetSuite. It is not automatically created by the sample or by PrintScaler.
Keeping printing outside the transaction-save path means a temporary printing failure does not need to block an employee from saving an invoice.
How the NetSuite-to-printer workflow works
The complete path is:
Eligible NetSuite invoice
-> Custom queue or scheduled script parameters
-> SuiteScript renders the invoice PDF
-> HTTPS request to PrintScaler
-> PrintScaler agent on the office computer
-> Local printer
The computer running the agent needs access to the printer and must be able to print to it locally. Your SuiteScript does not need that computer’s IP address, a VPN connection, or an inbound firewall rule.
The agent connects outward to PrintScaler over WebSocket. It starts automatically after reboots, updates itself, and reports the printers it discovers and their status.
For this tutorial, use a normal office printer and PDF output. Sending invoice PDFs as RAW printer commands is not appropriate unless you have intentionally generated a printer-specific command language instead of a PDF.
Set up NetSuite automatic printing with PrintScaler
1. Connect the destination printer
Install the PrintScaler agent on a Windows, macOS, Linux, or Raspberry Pi computer that can access the printer.
Then:
- Open the PrintScaler dashboard.
- Link the computer by entering the pairing code.
- Confirm that the intended printer appears.
- Use the dashboard’s test-page button.
- Record the printer ID for your integration.
Do not start troubleshooting SuiteScript until that test page prints correctly. A missing driver, disconnected USB cable, or incorrect operating-system printer setup will not be fixed by changing the API request.
Use a designated printer mapping rather than an employee’s operating-system default printer. If your workflow eventually serves multiple offices, maintain that mapping in your application configuration.
2. Prepare a known-good NetSuite invoice
Choose a test invoice and note its internal ID. Preview its PDF in NetSuite before writing integration code.
Check the transaction form, logo, page breaks, totals, and any Advanced PDF/HTML Template behavior your account uses. The delivery API cannot repair a badly rendered invoice.
The example uses N/render and render.transaction() with PDF output. It relies on the account’s applicable transaction rendering configuration; it does not explicitly select a custom form.
If your implementation requires a specific form, locale, or template-selection rule, configure that deliberately and test it with representative invoices. Include long invoices, non-ASCII customer names, and documents that span multiple pages.
3. Store credentials and create script parameters
Create a PrintScaler API key and store it using NetSuite’s API Secrets facility. The example assumes the secret has the script ID custsecret_printscaler_api_key.
Restrict access to the intended script and the api.printscaler.com domain using the controls available in your NetSuite account. Never put the key directly in source code, a client script, or a transaction field.
Create these custom parameters on the scheduled script record:
| Parameter ID | Purpose | Example |
|---|---|---|
custscript_ps_invoice_id |
Existing invoice internal ID | 48291 |
custscript_ps_printer_id |
Destination PrintScaler printer ID | 123 |
custscript_ps_print_revision |
Stable identifier for this print intent | original-v1 |
These names are examples you create yourself, not standard NetSuite fields.
For the first test, set the parameters on a deployment and run the script manually. A production worker should read equivalent values from its queue records instead.
4. Render and submit the invoice PDF
This SuiteScript 2.1 scheduled script renders one invoice and sends its base64 PDF contents to PrintScaler:
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/render', 'N/runtime', 'N/https', 'N/log'],
(render, runtime, https, log) => {
function execute() {
const script = runtime.getCurrentScript();
const invoiceId = Number(script.getParameter({
name: 'custscript_ps_invoice_id'
}));
const printerId = Number(script.getParameter({
name: 'custscript_ps_printer_id'
}));
const revision = String(script.getParameter({
name: 'custscript_ps_print_revision'
}) || 'original-v1');
if (!Number.isInteger(invoiceId) || invoiceId <= 0 ||
!Number.isInteger(printerId) || printerId <= 0) {
throw new Error('Valid invoice and printer IDs are required.');
}
if (!/^[A-Za-z0-9_-]{1,40}$/.test(revision)) {
throw new Error('Invalid print revision.');
}
const pdf = render.transaction({
entityId: invoiceId,
printMode: render.PrintMode.PDF,
inCustLocale: true
});
const authorization = https.createSecureString({
input: 'Bearer {custsecret_printscaler_api_key}'
});
const idempotencyKey =
`ns:${runtime.accountId}:invoice:${invoiceId}:${revision}`;
const response = https.post({
url: 'https://api.printscaler.com/v1/printjobs',
headers: {
'Authorization': authorization,
'Content-Type': 'application/json',
'X-Idempotency-Key': idempotencyKey
},
body: JSON.stringify({
printerId,
contentType: 'pdf_base64',
content: pdf.getContents(),
title: `NetSuite invoice ${invoiceId}`
})
});
const status = Number(response.code);
if (status < 200 || status >= 300) {
throw new Error(`Print submission returned HTTP ${status}`);
}
log.audit({
title: 'Invoice print submission accepted',
details: { invoiceId, printerId, revision, status }
});
}
return { execute };
});
NetSuite file contents for a binary PDF are base64-encoded, so the script uses pdf_base64. Do not base64-encode that string a second time.
The authorization header uses a NetSuite SecureString so the API secret does not need to be read into an ordinary JavaScript string. Configure and authorize the secret for this script before running it.
Review the print-job API reference when extending the payload. The required destination is printerId; the PDF bytes go in content, not in a local file path.
5. Run a controlled test
Run the script deployment against your test invoice and watch both systems:
- Check the NetSuite script execution log.
- Find the job in the PrintScaler dashboard.
- Inspect its state and history.
- Confirm the physical output at the intended printer.
- Check page size, margins, orientation, and legibility.
An accepted API request is not proof that paper has already emerged. PrintScaler exposes states including new, sent_to_client, queued, in_progress, done, error, cancelled, and expired.
For an initial test, use the dashboard to inspect these transitions. For production, store the returned job identifier according to the documented response format so your application can correlate later status information.
6. Add print options only after the basic path works
PDF printing supports options such as copies, duplex, paper size, tray, DPI, collate, color, fit to page, page ranges, rotation, and n-up.
However, the available choices depend on the destination printer. Read its capabilities through the API and use the documented option structure rather than guessing tray names or paper identifiers.
For invoices, decide whether duplex is appropriate, whether letterhead requires a specific tray, and whether fitting to the page would unexpectedly shrink the document. Keep a test invoice that makes these differences obvious.
Turn the test script into a reliable print queue
The sample intentionally processes one explicitly selected invoice. Production automation needs durable application state around that API call.
Record each print intent once
A custom NetSuite queue record might contain:
- Invoice internal ID and destination printer ID.
- Print revision or business-event identifier.
- Queue status and next attempt time.
- Attempt count and last error category.
- PrintScaler job ID after successful submission.
- Document snapshot reference, if required by your process.
Apply a uniqueness rule for the original print intent. Repeated transaction updates should not create repeated original-print records.
If multiple workers can claim work, implement an appropriate claim or locking strategy. Idempotency protects API submission retries, but it does not replace application-level queue design.
Reuse the same idempotency key after a timeout
A request can succeed even when the calling script never receives its response. Retrying with a new key can turn that uncertainty into a duplicate invoice.
The sample derives X-Idempotency-Key from the NetSuite account, invoice ID, and print revision. Keep those values stable when retrying the same intent. Create a different revision only when someone genuinely requests another print.
For the underlying retry pattern, see the guide to preventing duplicate print jobs.
Also preserve the intended document. If the invoice changes between attempts, regenerating its PDF can produce different content under the same key. For stronger auditability, render once, store an appropriately secured snapshot, and retry that snapshot.
Separate retries from reprints
Treat these cases differently:
- Submission timeout: retry the same intent with the same key.
- Rate limit or temporary service failure: retry later with backoff.
- Invalid credentials or request data: fix the configuration before retrying.
- Accepted job with an offline computer: track the existing job; do not submit another automatically.
- Operator-requested extra copy: create a new, auditable print intent.
PrintScaler permits 10 requests per second with a burst of 30. Control worker concurrency during bulk invoice processing, and account for NetSuite’s own script governance limits.
Jobs queue while the agent computer is offline and print when it returns, subject to configurable expiration. Choose an expiration appropriate for the business document rather than assuming an old invoice should always print days later.
Track completion outside the submission call
PrintScaler provides signed, retried webhooks, including printjob.state. A webhook receiver can validate the HMAC-SHA256 signature and update your integration’s status records.
That receiver is another component you must implement. Depending on your architecture, it may run in middleware that communicates with NetSuite rather than exposing a NetSuite endpoint directly.
Use the webhook documentation for implementation details. Keep “submitted,” “reported complete,” and “physically verified by an employee” distinct where your operational controls require it.
Troubleshooting NetSuite invoice printing
| Symptom | What to check first |
|---|---|
| Script fails before making the request | Invoice ID, execution-role permissions, PDF rendering, and script parameters |
| Secret cannot be used | API Secret script ID, authorized script, and allowed domain settings |
| API rejects authentication | Active API key and correct Bearer authorization setup |
| Request is accepted but nothing prints | Correct printer ID, agent connection, job history, and physical printer condition |
| PDF is malformed or unreadable | Confirm pdf_base64 and avoid encoding getContents() twice |
| Layout differs from the expected invoice | Transaction form, template configuration, paper size, and print options |
| Duplicate invoices appear | Duplicate queue records, changing idempotency keys, or uncontrolled reprint actions |
If PDF generation is unreliable, solve that inside NetSuite first. Save or preview the same rendered document independently before investigating printer delivery.
For unusually large invoices, account for SuiteScript memory, file-content, and execution limits. A secure, fetchable PDF URL with pdf_uri is another supported delivery format, but it requires a deliberate document-hosting design; a private NetSuite browser URL is not automatically accessible to an external service.
If you later route documents across offices, the multi-location printing guide covers destination selection in more depth.
Estimate costs by print request, not invoice pages
PrintScaler pricing is per print request, not per page. A single request containing a multipage invoice is therefore different from splitting that invoice into separate page-level requests.
The Free plan includes 100 prints per month and one connected computer, making it suitable for a small integration test. Starter is $9 per month with 5,000 included prints and three computers; Business is $29 per month with 30,000 included prints and 10 computers. Check the current pricing and overage rates when sizing production usage.
Include legitimate reprints and test jobs in your estimate. Separately, confirm the NetSuite permissions, scripting access, and governance capacity required by your implementation.
Start with one invoice and one printer
Reliable NetSuite automatic printing starts with a narrow test: render one known invoice, submit it to one known printer, and verify the physical result. Then add the business trigger, durable queue, stable idempotency keys, and job-state tracking.
Create a free PrintScaler account, connect your office printer, and test the delivery path before expanding the workflow to your daily invoice volume.
Frequently asked questions
Can NetSuite automatically print invoices without opening a browser?
Yes. A server-side SuiteScript can render an invoice PDF and submit it to a printing API, while a local agent delivers it to the printer. You must implement the trigger and integration; generating a PDF alone does not send it to a physical printer.
Does PrintScaler have a built-in NetSuite integration?
The workflow described here is a custom integration using SuiteScript and PrintScaler's HTTPS API. It does not depend on a built-in NetSuite connector or a marketplace package.
Can SuiteScript print directly to a local USB printer?
A cloud-executed SuiteScript cannot directly access a USB printer attached to an office computer. Install the PrintScaler agent on a computer with access to that printer, then submit print jobs using its printer ID.
How do I prevent duplicate NetSuite invoice prints?
Create one durable queue entry per print intent and reuse the same X-Idempotency-Key when retrying that submission. Treat an intentional reprint as a separate action with a new identifier, and do not resubmit jobs merely because the printer computer is offline.
Does a successful print API response mean the invoice has printed?
No. A successful submission means the API accepted the request, not necessarily that the printer has produced the document. Track the print job's state through the dashboard or a webhook-based integration.
Can I use my existing NetSuite invoice template?
The example uses NetSuite's transaction PDF rendering and relies on your account's applicable transaction form and template configuration. Preview representative invoices first, and explicitly configure form or template selection if your workflow requires it.