forked from linux/documentation
test pdf preview
This commit is contained in:
1 parent
6822336570
commit
ac317fd571
5 files changed
+90117
-7
No files matched your search
+26951
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
document$.subscribe(() => {
|
||||
// Point to your local copy
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = "/assets/pdf.worker.mjs";
|
||||
|
||||
document.querySelectorAll(".pdf-preview").forEach(el => {
|
||||
if (el.dataset.loaded) return; // prevent re-render on navigation
|
||||
el.dataset.loaded = "true";
|
||||
|
||||
const url = el.dataset.src;
|
||||
|
||||
pdfjsLib.getDocument(url).promise.then(pdf => {
|
||||
for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
|
||||
pdf.getPage(pageNum).then(page => {
|
||||
const viewport = page.getViewport({ scale: 1.5 });
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
canvas.width = viewport.width;
|
||||
canvas.height = viewport.height;
|
||||
canvas.style.width = "100%";
|
||||
canvas.style.display = "block";
|
||||
canvas.style.marginBottom = "8px";
|
||||
el.appendChild(canvas);
|
||||
page.render({ canvasContext: ctx, viewport });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,13 +3,11 @@
|
||||
Introduction to SSH given in the RSE Meeting on 05.05.2026:
|
||||

|
||||
|
||||
----
|
||||
|
||||
<!-- <iframe
|
||||
src="_static/2026-05-05_SSH_Deep_Dive.pdf"
|
||||
width="100%"
|
||||
height="600px"
|
||||
style="border: none; border-radius: 4px;">
|
||||
</iframe> -->
|
||||
<div class="pdf-preview" data-src="_static/2026-05-05_SSH_Deep_Dive.pdf"></div>
|
||||
|
||||
----
|
||||
|
||||
Example to create an SSH key:
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ extra_css = ["assets/asciinema-player.css"]
|
||||
#
|
||||
# Read more: https://zensical.org/docs/customization/#additional-javascript
|
||||
#extra_javascript = ["assets/javascript/extra.js"]
|
||||
extra_javascript = ["assets/asciinema-player.min.js"]
|
||||
extra_javascript = ["assets/asciinema-player.min.js", "pdf.mjs", "pdfviewer.js"]
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Section for configuring theme options
|
||||
|
||||
Reference in new issue
Block a user