python - Printing dynamic django view template -
i'm working on django app. have page displays log of items, , each item has "print label" link. @ moment, clicking link displays label particular item in popup screen, not send label printer. view function behind "print label" link shown below:
@login_required def print_label(request, id): s = item.objects.get(pk = id) return render_to_response('templates/label.html', {'s': s}, context_instance=requestcontext(request))
the html label shown below:
{% load humanize %} <head> <style type="text/css"> div{ min-width: 350px; max-width: 350px; text-align: center; } body{ font-family: arial; width: 370px; height: 560px; text-align: center; } </style> </head> <body> <div id="labelheader"> <img src="{{ static_url }}img/label-header.png" width="350px"> </div> <hr/> <p></p> <div id="destinationaddress"> <span style="font-size: xx-large; font-weight: bold;">{{ s.item_number }}</span> </p> destination: <br/> <strong>{{s.full_name}}</strong><br/> <strong>{{ s.address }}</strong><br/> <strong>{{s.city}}, {{s.state}}</strong><br/> <strong>tel: {{s.telephone}}</strong> </div> <p></p> <hr/> <div id="labelfooter"> <img src="{{ static_url }}img/label-footer.png" width="350px"> </div> </body>
my question is, how can send label displayed printer in same function? researched , found libraries (like xhtml2pdf, webkit2png, pdfcrowd, etc), they'll create pdf or image file of label , i'll have send printer. possible send straight printer without creating pdf copy of label? if so, please show me how achieve this.
your answers , suggestions highly welcome. thank you.
presumably, django app, it's client's printer need use. way tell user's browser print. need use javascript this: window.print()
.
Comments
Post a Comment