9832

Question:
Here is the code which generates pdf for me using Reportlab.
Now, it just shows the pdf in the browser, and after including 'attachment' in the resonse.header ['Content-Disposition'], it downloads the pdf.
But what i want is the rint option which comes you in the browser, which even allows you to choose your printer. is it possible ?
data = "raghav"
p = canvas.Canvas(self.response.out)
p.drawString(50, 700, data)
p.showPage()
self.response.headers['Content-Type'] = 'application/pdf'
self.response.headers['Content-Disposition'] = 'attachment;filename=testpdf.pdf'
p.save()
Answer1:according to <a href="http://blog.adlibre.org/2012/04/05/automatically-print-pdf-generated-reportlab/" rel="nofollow">http://blog.adlibre.org/2012/04/05/automatically-print-pdf-generated-reportlab/</a> you can add these two lines to get the desired result:
from reportlab.pdfbase import pdfdoc
pdfdoc.PDFCatalog.OpenAction = '<</S/JavaScript/JS(this.print\({bUI:true,bSilent:false,bShrinkToFit:true}\);)>>'
hope it helps :)