Embed pdf to open in new tab html

You can embed a PDF file in an HTML page and set it to open in a new tab using the following code:

<a rel="nofollow" target="_blank" href="path/to/your/pdf/file.pdf" target="_blank">View PDF</a>

Replace path/to/your/pdf/file.pdf with the actual path to your PDF file.

The target="_blank" attribute tells the browser to open the PDF file in a new tab instead of replacing the current page.

You can also use the object tag to embed the PDF file:

<object data="path/to/your/pdf/file.pdf" type="application/pdf" width="100%" height="500">
  <embed src="path/to/your/pdf/file.pdf" type="application/pdf" width="100%" height="500" />
</object>

This code will embed the PDF file in the page and set it to open in a new tab when clicked.

Alternatively, you can use the iframe tag to embed the PDF file:

<iframe src="path/to/your/pdf/file.pdf" frameborder="0" width="100%" height="500"></iframe>

This code will embed the PDF file in an iframe and set it to open in a new tab when clicked.

Note that the object, embed, and iframe tags may not work in all browsers, especially older versions. It's always a good idea to test your code in different browsers to ensure compatibility.

Also, you can use the pdf.js library to embed PDF files in HTML pages. It's a JavaScript library developed by Mozilla that allows you to embed PDF files in HTML pages and provides features such as zooming, panning, and printing.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pdf.min.js"></script>
<div id="pdf-viewer"></div>
<script>
  var pdf = new PDFDocument('path/to/your/pdf/file.pdf');
  pdf.render('pdf-viewer');
</script>

This code will embed the PDF file in a div element and provide features such as zooming and panning.