Closed bartonwelt closed 4 years ago
I figured this out with JavaScript. Trying to append the query parameters after the file URL resulted in the string being encoded so I had to add the params dynamically. There's probably a more clever way to do it in Rails but I didn't have the time.
.js
$(document).ready(function() {
let iframe = $(".pdf-js-viewer iframe");
iframe.attr("src", iframe.attr("src") + "#pagemode=bookmarks");
});
.html.erb
<div class="pdf-js-viewer">
<iframe src="<%= pdfjs.full_path(file: "#{file_path}") %>" title="webviewer" frameborder="0"></iframe>
</div>
Is there a way to pass viewer options with the helper as found here: https://github.com/mozilla/pdf.js/wiki/Viewer-options
Ex:
<%= pdfjs_viewer pdf_url: "/sample.pdf", style: :full, pagemode: :bookmarks %>
or:
<%= pdfjs_viewer pdf_url: "/sample.pdf?pagemode=bookmarks", style: :full, pagemode: :bookmarks %>