Skip to content

Commit

Permalink
try pdfjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Girard committed Mar 3, 2024
1 parent ea6e484 commit c3bbbd4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Users/jmgirard/embedpdf/_quarto.yml="0132EDC0"
/Users/jmgirard/embedpdf/example.qmd="489DF0D7"
4 changes: 2 additions & 2 deletions _extensions/embedpdf/embedpdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ end

function pdfobject(args)
local data = pandoc.utils.stringify(args[1])
local id = pandoc.utils.stringify(args[2])

--detect html
if quarto.doc.isFormat("html:js") then

return pandoc.RawInline('html', '<div id="results"></div><script src="https://unpkg.com/[email protected]/pdfobject.min.js"></script><script>let myPDF = PDFObject.embed("dummy.pdf", "#pdf", {forcePDFJS: true, PDFJS_URL: "/pdfjs/web/viewer.html"});</script>')
return pandoc.RawInline('html', '<div id="' .. id .. '"></div><script src="https://unpkg.com/[email protected]/pdfobject.min.js"></script><script>let myPDF = PDFObject.embed("../../' .. data .. '", "#' .. id .. '", {forcePDFJS: true, PDFJS_URL: "/pdfjs/web/viewer.html"});</script>')
else
end
end
6 changes: 3 additions & 3 deletions docs/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ <h2 class="anchored" data-anchor-id="you-can-also-use-embedpdf-as-an-alias">You
<section id="use-pdfobject-for-a-mobile-friendly-approach" class="level2">
<h2 class="anchored" data-anchor-id="use-pdfobject-for-a-mobile-friendly-approach">Use pdfobject for a mobile-friendly approach</h2>
<style>
.pdfobject-container {
#mypdf {
max-width: 100%;
width: 600px;
height: 600px;
Expand All @@ -141,15 +141,15 @@ <h2 class="anchored" data-anchor-id="use-pdfobject-for-a-mobile-friendly-approac
}
</style>
<pre><code>&lt;style&gt;
.pdfobject-container {
#mypdf {
max-width: 100%;
width: 600px;
height: 600px;
border: 10px solid rgba(0,0,200,.2);
margin: 0;
}
&lt;/style&gt;</code></pre>
<p><code>{{&lt; pdfjs dummy.pdf &gt;}}</code></p>
<p><code>{{&lt; pdfjs dummy.pdf mypdf &gt;}}</code></p>
<p></p><div><iframe id="pdf-js-viewer" src="/pdfjs/web/viewer.html?file=dummy.pdf" title="webviewer"></iframe></div><p></p>
</section>

Expand Down
8 changes: 4 additions & 4 deletions example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ title: "embedpdf Example"
## Use pdfobject for a mobile-friendly approach

<style>
.pdfobject-container {
#mypdf {
max-width: 100%;
width: 600px;
height: 600px;
Expand All @@ -104,7 +104,7 @@ title: "embedpdf Example"

```
<style>
.pdfobject-container {
#mypdf {
max-width: 100%;
width: 600px;
height: 600px;
Expand All @@ -114,7 +114,7 @@ title: "embedpdf Example"
</style>
```

`{{{< pdfjs dummy.pdf >}}}`
`{{{< pdfjs dummy.pdf mypdf >}}}`

{{< pdfjs dummy.pdf >}}
{{< pdfjs dummy.pdf mypdf >}}

0 comments on commit c3bbbd4

Please sign in to comment.