Hello guys,In this tutorial we will learn how to embed pdf file from google drive in our website.Normally,we can’t directly embed pdf file from google drive.For example go to your google drive and copy pdf file share link.

And then,Embed in html with iframe.
<iframe src="https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/view?usp=sharing" frameborder="1"width="640" height="480"></iframe>
The result is

We can’t embed pdf form google drive.But, i change google drive sharing link
https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/view?usp=sharing
To
https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/preview
And then,embed with iframe.
<iframe src="https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/preview" frameborder="1"width="640" height="480"></iframe>
The embed is working.

So,compare two link.
Original sharing link
https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/view?usp=sharing
Modified link
https://drive.google.com/file/d/1QgPO_Dr7DDS1RyTrtWiOr9slg2oy_79q/preview
The different between original sharing link and modified link is view?usp=sharing and preview.
So to embed pdf file from google drive,you need to change view?usp=sharing to preview in original sharing link.
And then, you can embed with <iframe>
The following code is example of embed pdf form google drive in PHP.
<?php
$orginal ="https://drive.google.com/file/d/1nUJxS1eURatAocjB9GJEUdREwPCZCBY_/view?usp=sharing" ;
$substr = substr( $orginal,32,-17);
?>
<iframe src="https://drive.google.com/file/d/<?php echo $substr; ?>/preview" width="640" height="480" ></iframe>