A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Add PDF preview next to edit form
Johann Bauera4573a8de8d4
diff --git a/src/documents/templates/admin/documents/document/change_form.html b/src/documents/templates/admin/documents/document/change_form.htmlindex 88fae955d..6edcbf2b1 100644--- a/src/documents/templates/admin/documents/document/change_form.html+++ b/src/documents/templates/admin/documents/document/change_form.html@@ -3,6 +3,10 @@{% block content %}{{ block.super }}+<div class="side-preview">+ <h2>Preview</h2>+ <object data="/fetch/preview/{{object_id}}"></object>+</div>{% if next_object %}<script type="text/javascript">//<![CDATA[@@ -17,6 +21,37 @@{% endblock content %}+{% block extrastyle %}+{{ block.super }}+<style>+.side-preview {+ width: 100%;+ height: 800px;+ clear: both;+}++.side-preview object {+ height: 100%;+ width: 100%;+}++@media screen and (min-width: 1500px) {+ #content-main {+ width: 50%;+ }+ #footer {+ padding: 0;+ }+ .side-preview {+ float: right;+ width: 40%;+ height: 80vh;+ clear: none;+ }+}+</style>+{% endblock %}+{% block footer %}{{ block.super }}diff --git a/src/documents/views.py b/src/documents/views.pyindex f72ca22b1..aca849c70 100644--- a/src/documents/views.py+++ b/src/documents/views.py@@ -69,7 +69,10 @@ class FetchView(SessionOrBasicAuthMixin, DetailView):content_type=content_types[self.object.file_type])- DISPOSITION = 'inline' if settings.INLINE_DOC else 'attachment'+ DISPOSITION = (+ 'inline' if settings.INLINE_DOC or self.kwargs["kind"] == 'preview'+ else 'attachment'+ )response["Content-Disposition"] = '{}; filename="{}"'.format(DISPOSITION, self.object.file_name)diff --git a/src/paperless/urls.py b/src/paperless/urls.pyindex 8da218b4e..4ab19b06f 100644--- a/src/paperless/urls.py+++ b/src/paperless/urls.py@@ -37,7 +37,7 @@ urlpatterns = [# File downloadsurl(- r"^fetch/(?P<kind>doc|thumb)/(?P<pk>\d+)$",+ r"^fetch/(?P<kind>doc|thumb|preview)/(?P<pk>\d+)$",FetchView.as_view(),name="fetch"),