Google Drive PDF Embed Code Generator
Generate responsive PDF embed code for your website.
Google Drive PDF Sharing Link
⚡ Generate Embed Code
✓ PDF Embed Code Generated!
HTML EMBED CODE
▣ Copy Embed Code
PDF PREVIEW LINK
↗ Open PDF Preview
↻ Generate Another Code
';codeBox.textContent=embedCode;
previewBox.textContent=previewUrl;result.style.display='block';result.scrollIntoView({
behavior:'smooth',
block:'nearest'
});}catch(e){
showError(e.message || 'Unable to generate embed code.');
}
}root.querySelector('#ap-pdf-generate')
.addEventListener('click',generate);input.addEventListener('keydown',function(e){
if(e.key==='Enter'){
e.preventDefault();
generate();
}
});// Open preview directly from a user click
open.addEventListener('click',function(e){
e.preventDefault();if(!previewUrl)return;const newTab=window.open(
previewUrl,
'_blank',
'noopener,noreferrer'
);if(!newTab){
// Fallback when browser blocks a new tab
window.location.href=previewUrl;
}
});// Copy embed code
copy.addEventListener('click',async function(){
if(!embedCode)return;try{
if(navigator.clipboard && window.isSecureContext){
await navigator.clipboard.writeText(embedCode);
}else{
const temp=document.createElement('textarea');
temp.value=embedCode;
temp.style.position='fixed';
temp.style.opacity='0';
root.appendChild(temp);
temp.select();const ok=document.execCommand('copy');
temp.remove();if(!ok)throw new Error('Copy failed');
}copy.textContent='✓ Copied Successfully!';}catch(e){
copy.textContent='Unable to copy - select code manually';
}setTimeout(function(){
copy.textContent='▣ Copy Embed Code';
},2200);
});// Reset tool
root.querySelector('#ap-pdf-reset')
.addEventListener('click',function(){
input.value='';
embedCode='';
previewUrl='';
result.style.display='none';
error.style.display='none';
copy.textContent='▣ Copy Embed Code';
input.focus();
});input.addEventListener('input',function(){
result.style.display='none';
error.style.display='none';
embedCode='';
previewUrl='';
});})();
Google Drive PDF Embed Code Generator I had multiple files on Google Drive and wanted to share it on my blog. But, I had to use third party plugin which even makes my blog heavier.
Here, I found that with some customization on Google Drive Link I can easily embed the PDF on any post.
Also, when I upload my pdf files on Google Drive and share it, the size of my website remains lighter. So, here, you can use this tool simplified to generate the embed code .
How to use Google Drive PDF Embed Code Generator ? Step 1: Share you PDF. Step 2: Copy Link Step 3: Go to Embed Code Generator. Step 4: Copy the code. Step 5: PASTE it in your post.
Related