I'm trying to utilize the Google Docs Viewer solution to display a pdf in an iframe. It works fine when the pdf is in a public directory but doesn't work when the pdfs files are not private. I've seen this issue come up in different SO threads (but not as the subject), with no definitive solution.
Is there a way to tweak the code (below) to use a private file path to the pdf? Or, failing that, is there some other alternative to displaying pdfs in html that are private?
Here's the code I'm trying to mod and thanks for any help!
<script type="text/javascript">
document.addEventListener('DataPageReady', function (event){
if(!("pdf_file_path" == "")){
embed_pdf();
}
});
function embed_pdf(){
var google_link= "https://docs.google.com/gview?url=";
var google_param = "&embedded=true";
var pdf_link = "pdf_file_path";
var encoded_pdf_link = encodeURIComponent(pdf_link);
var iframe_window = document.getElementById("iframe_pdf");
iframe_window.style.display = "block";
iframe_window.src=google_link + encoded_pdf_link + google_param;
}
</script>
<iframe id="iframe_pdf" style="width:100%; height: 100%; display: none;" align="middle" frameborder="0"></iframe>