Fix document print view

This commit is contained in:
Roberto Rosario
2011-12-04 02:37:11 -04:00
parent 64e73a9c9d
commit fafadfaca2
5 changed files with 21 additions and 20 deletions

View File

@@ -110,7 +110,7 @@ def get_page_count(input_filepath):
return backend.get_page_count(input_filepath) return backend.get_page_count(input_filepath)
'''
def get_document_dimensions(document, *args, **kwargs): def get_document_dimensions(document, *args, **kwargs):
document_filepath = create_image_cache_filename(document.checksum, *args, **kwargs) document_filepath = create_image_cache_filename(document.checksum, *args, **kwargs)
if os.path.exists(document_filepath): if os.path.exists(document_filepath):
@@ -118,7 +118,7 @@ def get_document_dimensions(document, *args, **kwargs):
return [int(dimension) for dimension in backend.identify_file(unicode(document_filepath), options).split()] return [int(dimension) for dimension in backend.identify_file(unicode(document_filepath), options).split()]
else: else:
return [0, 0] return [0, 0]
'''
def get_available_transformations_choices(): def get_available_transformations_choices():
result = [] result = []

View File

@@ -271,10 +271,10 @@ class DocumentTypeSelectForm(forms.Form):
class PrintForm(forms.Form): class PrintForm(forms.Form):
page_size = forms.ChoiceField(choices=PAGE_SIZE_CHOICES, initial=DEFAULT_PAPER_SIZE, label=_(u'Page size'), required=False) #page_size = forms.ChoiceField(choices=PAGE_SIZE_CHOICES, initial=DEFAULT_PAPER_SIZE, label=_(u'Page size'), required=False)
custom_page_width = forms.CharField(label=_(u'Custom page width'), required=False) #custom_page_width = forms.CharField(label=_(u'Custom page width'), required=False)
custom_page_height = forms.CharField(label=_(u'Custom page height'), required=False) #custom_page_height = forms.CharField(label=_(u'Custom page height'), required=False)
page_orientation = forms.ChoiceField(choices=PAGE_ORIENTATION_CHOICES, initial=DEFAULT_PAGE_ORIENTATION, label=_(u'Page orientation'), required=True) #page_orientation = forms.ChoiceField(choices=PAGE_ORIENTATION_CHOICES, initial=DEFAULT_PAGE_ORIENTATION, label=_(u'Page orientation'), required=True)
page_range = forms.CharField(label=_(u'Page range'), required=False) page_range = forms.CharField(label=_(u'Page range'), required=False)

View File

@@ -1,5 +1,5 @@
{% load project_tags %} {% load project_tags %}
{% load printing_tags %} {#{% load printing_tags %}#}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -48,9 +48,10 @@
</head> </head>
<body> <body>
{% for page in pages %} {% for page in pages %}
{% get_document_size object %} {#{% get_document_size object %}#}
<div class="{% if forloop.counter > 1 and not forloop.last %}break{% endif %}"> <div class="{% if forloop.counter > 1 and not forloop.last %}break{% endif %}">
<img src="{% url document_display_print object.id %}?page={{ page.page_number }}" {% if document_aspect > page_aspect %}width="97%"{% else %}height="97%"{% endif %} /> {#<img src="{% url document_display_print object.id %}?page={{ page.page_number }}" {% if document_aspect > page_aspect %}width="97%"{% else %}height="97%"{% endif %} />#}
<img src="{% url document_display_print object.id %}?page={{ page.page_number }}" />
</div> </div>
{% endfor %} {% endfor %}

View File

@@ -1,6 +1,6 @@
from django.template import Library, Node, Variable from django.template import Library, Node, Variable
from converter.api import get_document_dimensions from converter.api import get_dimensions
from documents.conf.settings import PRINT_SIZE from documents.conf.settings import PRINT_SIZE
@@ -13,7 +13,7 @@ class GetImageSizeNode(Node):
def render(self, context): def render(self, context):
document = Variable(self.document).resolve(context) document = Variable(self.document).resolve(context)
width, height = get_document_dimensions(document) width, height = get_dimensions(document)
context[u'document_width'], context['document_height'] = width, height context[u'document_width'], context['document_height'] = width, height
context[u'document_aspect'] = float(width) / float(height) context[u'document_aspect'] = float(width) / float(height)
return u'' return u''

View File

@@ -799,18 +799,18 @@ def document_print(request, document_id):
hard_copy_arguments['page_range'] = form.cleaned_data['page_range'] hard_copy_arguments['page_range'] = form.cleaned_data['page_range']
# Compute page width and height # Compute page width and height
if form.cleaned_data['custom_page_width'] and form.cleaned_data['custom_page_height']: #if form.cleaned_data['custom_page_width'] and form.cleaned_data['custom_page_height']:
page_width = form.cleaned_data['custom_page_width'] # page_width = form.cleaned_data['custom_page_width']
page_height = form.cleaned_data['custom_page_height'] # page_height = form.cleaned_data['custom_page_height']
elif form.cleaned_data['page_size']: #elif form.cleaned_data['page_size']:
page_width, page_height = dict(PAGE_SIZE_DIMENSIONS)[form.cleaned_data['page_size']] # page_width, page_height = dict(PAGE_SIZE_DIMENSIONS)[form.cleaned_data['page_size']]
# Page orientation # Page orientation
if form.cleaned_data['page_orientation'] == PAGE_ORIENTATION_LANDSCAPE: #if form.cleaned_data['page_orientation'] == PAGE_ORIENTATION_LANDSCAPE:
page_width, page_height = page_height, page_width # page_width, page_height = page_height, page_width
hard_copy_arguments['page_width'] = page_width #hard_copy_arguments['page_width'] = page_width
hard_copy_arguments['page_height'] = page_height #hard_copy_arguments['page_height'] = page_height
new_url = [reverse('document_hard_copy', args=[document_id])] new_url = [reverse('document_hard_copy', args=[document_id])]
if hard_copy_arguments: if hard_copy_arguments: