14 minutes Read

Published On

How to make PDF Inline?

How are headers added in the server response to make PDF Inline?

In this blog, I will be showing you how you can open your advanced PDF in a new tab. As the
The default behaviour of the browser is to download it. With the help of some quick changes, you can achieve it.

Pre-requisites
– NetSuite Account
– Knowledge of Suite Script
– Knowledge of Advanced PDF

CTA - NetSuite Homepage Banner

Assumptions
This article will not cover the PDF & button creation aspects, assuming that you are familiar with it.

Scenario
Let us suppose a button on any record in NetSuite that triggers a SuiteLet on its click to show PDF file in a new tab.

Default Behavior
Browser’s default behaviour is to download PDF instead of opening it in a new tab.

Expected Result
To open the PDF in a new tab with the click of a button.

Solution
To open PDF in a new tab after a button click, we have to change the headers of the server response object.
By default, the server response headers are set to download the PDF. The main two headers that need to be added are:

Content-Type: application/pdf” and “Content-Disposition: inline;
filename=”report.pdf’’. By default, Content-Disposition set is ’attachment’ and Content-Type is
‘application/octet-stream’, we need to change Content-Type to ‘application/octet-stream’ and
Content-Disposition to ‘inline’. Set these headers in the server’s response, and you will see the magic.

CTA - NetSuite Customization Banner

Before rendering the PDF, you must set these headers in your ‘context response object’. Here is a piece of the snippet to that:

const { response } = context;
const renderer = render.create();
response.addHeader({
name: ‘Content-Type:’,
value: ‘application/pdf’
});
response.addHeader({
name: ‘Content-Disposition’,
value: ‘inline‘
});
renderer.renderPdfToResponse({
response: response
});

Table of Contents

Contact Us

By submitting this form, you agree to our privacy policy and terms of service.

Related resources you might be interested in

Deeper in to NetSuite, Development & Customization
Deeper in to NetSuite, Operations & Supply Chain

We'd love to help you with all your NetSuite needs

Folio3 Your Top Choice:

Middle East Partner 2025
education award 2025
Winner Award
Software and IT Services 2024
Financial-Services-2023
SuiteCommerce 2023

Let's discuss your NetSuite needs

Hello, How can we help you?