Skip to content

Commit b8f16b5

Browse files
committed
simplified viewer + fixed characters escaping
1 parent 752df5a commit b8f16b5

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

cookbook/templates/recipe_view.html

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@
99
{% block extra_head %}
1010
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-checkbox.min.css"
1111
integrity="sha384-ICB8i/maQ/5+tGLDUEcswB7Ch+OO9Oj8Z4Ov/Gs0gxqfTgLLkD3F43MhcEJ2x6/D" crossorigin="anonymous">
12+
13+
14+
<!-- prevent weired character stuff escaping the pdf box -->
15+
<style>
16+
.textLayer > span {
17+
color: transparent;
18+
position: absolute;
19+
white-space: pre;
20+
cursor: text;
21+
transform-origin: 0% 0%;
22+
}
23+
</style>
24+
1225
{% endblock %}
1326

1427
{% block content %}
@@ -196,15 +209,9 @@ <h5 class="card-title">{% trans 'External recipe' %}</h5>
196209

197210
var container = document.getElementById("viewerContainer");
198211

199-
// (Optionally) enable hyperlinks within PDF files.
200-
var pdfLinkService = new pdfjsViewer.PDFLinkService();
201-
202-
203212
var pdfViewer = new pdfjsViewer.PDFViewer({
204213
container: container,
205-
linkService: pdfLinkService,
206214
});
207-
pdfLinkService.setViewer(pdfViewer);
208215

209216
document.addEventListener("pagesinit", function () {
210217
// We can use pdfViewer now, e.g. let's change default scale.
@@ -215,12 +222,12 @@ <h5 class="card-title">{% trans 'External recipe' %}</h5>
215222
var loadingTask = pdfjsLib.getDocument({
216223
data: base64Pdf
217224
});
225+
218226
loadingTask.promise.then(function (pdfDocument) {
219227
// Document loaded, specifying document for the viewer and
220228
// the (optional) linkService.
221229
pdfViewer.setDocument(pdfDocument);
222230

223-
pdfLinkService.setDocument(pdfDocument, null);
224231
});
225232
}
226233

0 commit comments

Comments
 (0)