r/sharepoint • • 5d ago

SharePoint Online SharePoint HTML Pages: Any way to bypass the SharePoint PDF viewer and open PDFs directly in the browser?

My tenant recently got support for SharePoint HTML pages, and I've been rebuilding some internal pages using HTML because the layout and formatting options are much cleaner than traditional SharePoint pages with web parts.

Before this, I was using a modern .aspx page containing several Document Library web parts. With custom column formatting, I was able to get PDF links to open directly in the browser's native PDF viewer (Chrome/Edge) instead of the SharePoint PDF viewer.

That solution worked well, but the page itself wasn't very visually appealing because it was basically a collection of document library web parts.

Now I've moved the content into an HTML page and am generating links to files manually. The problem is that every PDF link I click gets intercepted and opened in the SharePoint PDF viewer. Our users only have read permissions, so they can't really interact with the document there and often have to download it manually just to view it.

Things I've already tried:

  • Using direct document URLs
  • Adding ?download=1
  • Adding ?web=0
  • Opening links in a new tab (target="_blank")
  • Using JavaScript click handlers and redirects
  • Using the document's direct download URL
  • Reusing logic from SharePoint column formatting that works inside a document library

Oddly, if a user right-clicks the PDF link and chooses Open in New Tab, the PDF opens directly in the browser viewer as expected. It's only a normal left-click that gets hijacked by SharePoint's PDF experience.

Has anyone found a way to force PDFs clicked from a SharePoint HTML page to open in the browser's native PDF viewer instead of the SharePoint PDF viewer?

At this point I'm wondering if SharePoint is intercepting navigation events from HTML pages and there's simply no supported way around it. I'd love to know if anyone has found a workaround, whether that's a special URL format, JavaScript trick, SharePoint setting, or something else entirely.

3 Upvotes

3 comments sorted by

4

u/DiscoQuebrado 5d ago

in your hyperlinks, try appending '#' to the href parameter, just after the file extension. <a href="path/to/doc.pdf#">doc.pdf</a>

4

u/718hutfission 5d ago

Try this format: https://tenant.sharepoint.com/sites/sitename/shared%20documents/folder/doc.pdf

You have to type this out yourself, not click through to the folder where the document is housed.

Copy and paste that and see if it opens natively in the browser.

If it does, make your clickable links using that URL

1

u/mkashman MVP 9h ago

This is a nice, relevant LI article abt the technical makeup of the new SharePoint HTML pages — pros and cons, from SP community member, Stefan Bauer: https://n8d.at/anatomy-of-sharepoint-html-pages-explained/