Home » Did you know? » How to make PDF Inline?

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.

– NetSuite Account
– Knowledge of Suite Script
– Knowledge of Advanced PDF

CTA - NetSuite Homepage Banner

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

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.

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();
name: ‘Content-Type:’,
value: ‘application/pdf’
name: ‘Content-Disposition’,
value: ‘inline‘
response: response

Get In Touch With Our Experts

    Get In Touch With Our Experts

      I have read and agree to the Privacy Policy of Folio3
      I agree to be contacted by Phone or Email by Folio3

      Get in touch with the


      End-to-end NetSuite Servicing Agency

      Tell us how may we assist you!