Displaying PDF Content as Binary Data in Browser Window Using JavaScript

Problem Context

I have a PDF document represented as a base64 or raw string format, and I’m struggling to render it correctly in a new browser window. When I attempt to use window.open() with the PDF string, the browser interprets it as HTML text instead of a PDF file.

Specific Challenge

  • Current method of opening PDF string results in displaying text content
  • Need a way to force browser to recognize and render the content as a PDF
  • Want to open the PDF string in a new browser tab/window preserving its document format

Potential Approach Needed

Looking for a JavaScript solution that can convert the PDF string into a proper binary stream or use a data URI that browsers will interpret as a PDF document.

hey mate, try using URL.createObjectURL() - it works gr8 for dis! just convert da pdf to blob n u should b good 2 go. worked 4 me b4 :+1: make sure u use type: 'application/pdf' n it shud open nice n clean