-
-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified viewer + fixed characters escaping
- Loading branch information
1 parent
752df5a
commit b8f16b5
Showing
1 changed file
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,19 @@ | |
{% block extra_head %} | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-checkbox.min.css" | ||
integrity="sha384-ICB8i/maQ/5+tGLDUEcswB7Ch+OO9Oj8Z4Ov/Gs0gxqfTgLLkD3F43MhcEJ2x6/D" crossorigin="anonymous"> | ||
|
||
|
||
<!-- prevent weired character stuff escaping the pdf box --> | ||
<style> | ||
.textLayer > span { | ||
color: transparent; | ||
position: absolute; | ||
white-space: pre; | ||
cursor: text; | ||
transform-origin: 0% 0%; | ||
} | ||
</style> | ||
|
||
{% endblock %} | ||
|
||
{% block content %} | ||
|
@@ -196,15 +209,9 @@ <h5 class="card-title">{% trans 'External recipe' %}</h5> | |
|
||
var container = document.getElementById("viewerContainer"); | ||
|
||
// (Optionally) enable hyperlinks within PDF files. | ||
var pdfLinkService = new pdfjsViewer.PDFLinkService(); | ||
|
||
|
||
var pdfViewer = new pdfjsViewer.PDFViewer({ | ||
container: container, | ||
linkService: pdfLinkService, | ||
}); | ||
pdfLinkService.setViewer(pdfViewer); | ||
|
||
document.addEventListener("pagesinit", function () { | ||
// We can use pdfViewer now, e.g. let's change default scale. | ||
|
@@ -215,12 +222,12 @@ <h5 class="card-title">{% trans 'External recipe' %}</h5> | |
var loadingTask = pdfjsLib.getDocument({ | ||
data: base64Pdf | ||
}); | ||
|
||
loadingTask.promise.then(function (pdfDocument) { | ||
// Document loaded, specifying document for the viewer and | ||
// the (optional) linkService. | ||
pdfViewer.setDocument(pdfDocument); | ||
|
||
pdfLinkService.setDocument(pdfDocument, null); | ||
}); | ||
} | ||
|
||
|