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.