mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Add PDF preview next to edit form
This commit is contained in:
		
							parent
							
								
									5317019d71
								
							
						
					
					
						commit
						a4573a8de8
					
				@ -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 }}
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@ urlpatterns = [
 | 
			
		||||
 | 
			
		||||
    # File downloads
 | 
			
		||||
    url(
 | 
			
		||||
        r"^fetch/(?P<kind>doc|thumb)/(?P<pk>\d+)$",
 | 
			
		||||
        r"^fetch/(?P<kind>doc|thumb|preview)/(?P<pk>\d+)$",
 | 
			
		||||
        FetchView.as_view(),
 | 
			
		||||
        name="fetch"
 | 
			
		||||
    ),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user