print option with django application

871 views
Skip to first unread message

Ketul Suthar

unread,
Dec 19, 2017, 7:40:25 AM12/19/17
to Django users
I want to print data from database when user click on print button.

how can I achieve it ?

Is there any in-built module in djnago for printing data ?

Jason

unread,
Dec 19, 2017, 8:08:33 AM12/19/17
to Django users
if you just want to print data that's already on the page, but in different style, you need to implement a print-specific CSS stylesheet for your templates

if you want to print data that doesn't exist in the page, there's no way to do that.  You can implement a server side view that will trigger a download response to the browser, but forcing an automatic print is not doable.

Larry Martell

unread,
Dec 19, 2017, 8:48:27 AM12/19/17
to django...@googlegroups.com
You cannot force the user to print. What I do in these situations is
generate a pfd (with wkhtmltopdf) and then the user can print that.

johnf

unread,
Dec 19, 2017, 9:39:21 AM12/19/17
to django...@googlegroups.com
I wonder what solutions there are for print from a django app? Is it
possible to use reportlab for example.  Or is there some other solution
that is normally used from django apps?

Johnf

Matthew Pava

unread,
Dec 19, 2017, 10:18:28 AM12/19/17
to django...@googlegroups.com
We use gsprint (for Windows printing) and Ghostscript.
http://pages.cs.wisc.edu/~ghost/gsview/gsprint.htm
https://www.ghostscript.com/

We have generic print view, and when users click on a button on the UI, our app generates a PDF and then sends that to a printer on the local network. The printers are all set up under the user who is running the web server, in this case, Apache. To print to printers at the user's desk, we turned on print sharing for those printers and set up the web server user to be able to print to those from the server hosting the webserver. We have a model, ComputerProfile, that associates a shared printer with a client computer. If the user is logged into that computer, the app choose the printer at that computer. There is also a default printer as a fall back.

Yes, you can print directly to a printer from Django (or any web app) using this method.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d7bf8abe-f500-f97d-d9bd-836d12620ff7%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages