Skip to content

Commit

Permalink
simplified viewer + fixed characters escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Feb 19, 2020
1 parent 752df5a commit b8f16b5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cookbook/templates/recipe_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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.
Expand All @@ -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);
});
}

Expand Down

0 comments on commit b8f16b5

Please sign in to comment.