# Display PDF in a new tab?

**URL:** <https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456>\
**Category:** Questions\
**Created:** [February 26, 2026, 12:14am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456 "2026-02-26T00:14:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom47](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/tom47/32/6961_2.png) [@Tom47](https://forum.pinegrow.com/u/Tom47)\
**Post date:** [February 26, 2026, 12:14am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/1 "2026-02-26T00:14:22Z")

</div>

How do I enter code to display a PDF in a new window or tab instead of downloading the file? I have put ‘\_blank’ in the Target field of the ‘a’ object, and I have also asked the AI assistant (who did the same thing). But testing using the view button in Pinegrow (on Safari 26.3) always leads to the file being downloaded instead of displayed. Also tried pasting the site URL into Chrome (version 145.0.7632.117), but the behavior is the same.

---

<div class="post-metadata">

**Author:** ![PeteSharp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/petesharp/32/7134_2.png) [@PeteSharp](https://forum.pinegrow.com/u/PeteSharp)\
**Post date:** [February 26, 2026, 12:26am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/2 "2026-02-26T00:26:12Z")

</div>

You can try adding this to your htaccess file.

This applies a header rule for handling pdf files, so the browser will just show them, not download the file.

```auto
<FilesMatch "\.pdf$">
    Header set Content-Type "application/pdf"
    Header set Content-Disposition "inline"
</FilesMatch>

```

---

<div class="post-metadata">

**Author:** ![Tom47](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/tom47/32/6961_2.png) [@Tom47](https://forum.pinegrow.com/u/Tom47)\
**Post date:** [February 26, 2026, 1:55am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/3 "2026-02-26T01:55:01Z")

</div>

Thanks, Pete, for responding! Sorry, I am a bit of a newbie, so I am not sure where to find this “htaccess” file. I do not have a file with that name in my project, even under the directories that Pinegrow defines to support Tailwind. Or is this something that should go in the server? I am using the internal server on my MacBook Pro to test the page.

---

<div class="post-metadata">

**Author:** ![Jerry](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/jerry/32/6247_2.png) [@Jerry](https://forum.pinegrow.com/u/Jerry)\
**Post date:** [February 26, 2026, 2:45am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/4 "2026-02-26T02:45:30Z")

</div>

You could try using the HTML attribute `onclick="window.open(...)"`. This should open your PDF in a new tab. Your button would look like:

```auto
<button onclick="window.open('my-doc.pdf', '_blank', 'noopener,noreferrer');">
  Button to open PDF in a new tab
</button>

```

@PeteSharp solution is more full proof though but requires modification of the .htaccess file on the server. Don’t forget to backup the .htaccess file before modifying 😇

---

<div class="post-metadata">

**Author:** ![PeteSharp](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/petesharp/32/7134_2.png) [@PeteSharp](https://forum.pinegrow.com/u/PeteSharp)\
**Post date:** [February 26, 2026, 3:53am UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/5 "2026-02-26T03:53:11Z")

</div>

Javascript can’t override the HTTP header setting. Modifying the .htaccess ensures the header is set, and it works with just a link.

> [@Tom47](#):
>
> Or is this something that should go in the server?

It’s a hidden file in the root of your hosting.

(This is assuming you have Apache or Litespeed on your hosting)

---

<div class="post-metadata">

**Author:** ![Tom47](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/tom47/32/6961_2.png) [@Tom47](https://forum.pinegrow.com/u/Tom47)\
**Post date:** [February 26, 2026, 6:45pm UTC](https://forum.pinegrow.com/t/display-pdf-in-a-new-tab/11456/6 "2026-02-26T18:45:36Z")

</div>

OK, I see that this is a server issue that I will have to test when the site is deployed. I was simply testing it on my Mac using the “view in browser” button in Pinegrow, where (I guess) my own laptop is the server. (It’s a bit too bad that I can’t test this functionality before I actually deploy the site.)

Thanks for your help!
