What are the advantages and disadvantages of using base64 encoding for embedding PDF files in HTML using PHP?

When embedding PDF files in HTML using PHP, one common approach is to base64 encode the PDF file and embed it directly into the HTML code. This method allows for easy embedding and displaying of the PDF file without the need for separate file hosting. However, base64 encoding can increase the size of the HTML file significantly, leading to slower loading times. Additionally, it may not be the most efficient method for larger PDF files.

<?php
// Read the PDF file
$pdf_file = 'example.pdf';
$pdf_data = file_get_contents($pdf_file);

// Encode the PDF file to base64
$pdf_base64 = base64_encode($pdf_data);

// Embed the base64 encoded PDF file in HTML
echo '<embed src="data:application/pdf;base64,'.$pdf_base64.'" type="application/pdf" />';
?>