Embed a PDF as a webpage
<?php | |
$copyright = 'Copyright 2020, Acme Inc.'; // copyright info of PDF file | |
$pdfPath = '/document.pdf'; // path to PDF file | |
$pdfTitle = 'Embedded PDF'; // title of PDF document | |
?><!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title><?= $pdfTitle; ?></title> | |
<meta name="copyright" content="<?= $copyright; ?>" /> | |
<style type="text/css"> | |
body,html{height:100%}body{background-color: rgb(82,86,89);margin:0}.hidden{display:none!important;}.container{overflow:hidden;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:100%;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;padding:0;margin:0} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<iframe src="<?= $pdfPath; ?>" type="application/pdf" width="100%" height="100%"></iframe> | |
</div> | |
<script> | |
if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) { | |
document.querySelector('.container').classList.add('hidden'); | |
document.location.href = "<?= $pdfPath; ?>"; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment