summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2011-02-26 03:08:58 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2011-02-26 03:08:58 +0100
commit83b44dee1b92f53a37084b849b90a9a1c6b8c2e0 (patch)
tree2a6001ff17e4b3b38708176f46ac78fbab83125b
parenta9ba75e402a36f2eb43b34bc860befe25ab12861 (diff)
downloadIshtar-83b44dee1b92f53a37084b849b90a9a1c6b8c2e0.tar.bz2
Ishtar-83b44dee1b92f53a37084b849b90a9a1c6b8c2e0.zip
Better PDF export(refs #227)
-rw-r--r--ishtar/furnitures/views.py7
-rw-r--r--ishtar/templates/sheet_file.html4
-rw-r--r--ishtar/templates/sheet_file_pdf.html14
-rw-r--r--static/media/style_basic.css94
4 files changed, 88 insertions, 31 deletions
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py
index e874e8cc2..59faeca47 100644
--- a/ishtar/furnitures/views.py
+++ b/ishtar/furnitures/views.py
@@ -290,11 +290,12 @@ def show_item(model, name):
response.write(odtfile)
return response
elif doc_type == 'pdf':
- tpl = loader.get_template('sheet_%s.html' % name)
+ tpl = loader.get_template('sheet_%s_pdf.html' % name)
content = tpl.render(context_instance)
result = StringIO.StringIO()
- pdf = pisa.pisaDocument(StringIO.StringIO(content.encode("utf-8")),
- result)
+ html = content.encode('utf-8')
+ html = html.replace("<table", "<pdf:nextpage/><table repeat='1'")
+ pdf = pisa.pisaDocument(StringIO.StringIO(html), result)
response = HttpResponse(result.getvalue(),
mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=%s.pdf' % \
diff --git a/ishtar/templates/sheet_file.html b/ishtar/templates/sheet_file.html
index 865acca41..0e46f7a6d 100644
--- a/ishtar/templates/sheet_file.html
+++ b/ishtar/templates/sheet_file.html
@@ -80,7 +80,7 @@
<th>{% trans "In charge" %}</th>
<th>{% trans "Start date" %}</th>
<th>{% trans "End date" %}</th>
- <th>&nbsp;</th>
+ <th class='link'>&nbsp;</th>
</tr>
{% for operation in item.operations.all %}
<tr>
@@ -91,7 +91,7 @@
<td class='string'>{{operation.in_charge|default:""}}</td>
<td>{{operation.start_date|default:""}}</td>
<td>{{operation.end_date|default:""}}</td>
- <td><a href="#{#{%url show-operation operation.pk%}#}">{% trans "Details" %}</a></td>
+ <td class='link'><a href="#{#{%url show-operation operation.pk%}#}">{% trans "Details" %}</a></td>
</tr>
{% empty %}
<tr><td colspan="8" class='no_items'>{% trans "No operation associated to this archaelogical file" %}</td></tr>
diff --git a/ishtar/templates/sheet_file_pdf.html b/ishtar/templates/sheet_file_pdf.html
new file mode 100644
index 000000000..2a23cb6a4
--- /dev/null
+++ b/ishtar/templates/sheet_file_pdf.html
@@ -0,0 +1,14 @@
+{% extends "sheet_file.html" %}
+{% block main_head %}
+{{ block.super }}
+<div id="pdfheader">
+Ishtar &ndash; {{APP_NAME}} &ndash; {{item}}
+</div>
+{% endblock %}
+{%block main_foot%}
+<div id="pdffooter">
+&ndash; <pdf:pagenumber/> &ndash;
+</div>
+</body>
+</html>
+{%endblock%}
diff --git a/static/media/style_basic.css b/static/media/style_basic.css
index ec96ecfce..d624ae09c 100644
--- a/static/media/style_basic.css
+++ b/static/media/style_basic.css
@@ -1,45 +1,87 @@
-#window{
- width:100%;
- position:relative;
- display:block;
- height:100%;
- left:0;
- margin:0;
+@page {
+ size: a4 portrait;
+ margin: 2.5cm 1cm 2.5cm 1cm;
+ background-image: url("images/ishtar-bg.jpg");
+ @frame footer {
+ -pdf-frame-content: pdffooter;
+ bottom: 1cm;
+ margin-left: 1cm;
+ margin-right: 1cm;
+ height: 1cm;
+ }
+ @frame header {
+ -pdf-frame-content: pdfheader;
+ top: 1.2cm;
+ margin-left: 1cm;
+ margin-right: 1cm;
+ height: 1.5cm;
+ }
}
-#window table{
- font-size:1em;
- margin:0;
+label{
+ display:inline;
+ font-weight:bold;
+}
+
+table{
+ margin:10px;
width:100%;
+ border: none;
border-collapse:collapse;
}
-#window .head{
- display:none;
+caption, h3{
+ display:block;
+ text-align:center;
+ font-size:1.5em;
}
-#window .tool{
- display:none;
+th{
+ text-align:center;
+ border-bottom:2px solid #922;
}
-#window .body{
- position:relative;
+td{
+ margin:0;
padding:0;
- top:0;
- bottom:0;
- width:100%;
+ padding-top:4px;
+ text-align:right;
+ border:1px solid #EEE;
+ border-top:none;
+ font-size:0.9em;
}
-#window label{
- display:inline;
- font-weight:bold;
+.link{
+ display:None;
}
-#window span.value{
- display:inline;
+.string{
+ text-align:left;
+}
+
+.no_items{
+ text-align:center;
+ font-style:italic;
+}
+
+.head{
+ display:none;
+}
+
+.tool{
+ display:none;
+}
+
+p{
+ margin:0.2em;
}
-#window p{
- margin:0.3em;
+#pdffooter, #pdfheader{
+ text-align:center;
}
+#pdfheader{
+ font-weight:bold;
+ width:100%;
+ border-bottom:1px solid #922;
+}