def on_pdf_button_clicked(self, button):
     from PrintDialog import PrintDialogHandler
     from xhtml2pdf import pisa
     f = self.html_code.replace("€","€")
     g = file(Environment.tempDir + ".temp.pdf", "wb")
     pbar(self.pbar, pulse=True, text="GENERAZIONE STAMPA ATTENDERE")
     pisa.CreatePDF(str(f), g)
     g .close()
     pbar(self.pbar, stop=True)
     anag = PrintDialogHandler(self, self.windowTitle)
     anagWindow = anag.getTopLevel()
     returnWindow = self.bodyWidget.getTopLevel().get_toplevel()
     anagWindow.set_transient_for(returnWindow)
     anagWindow.show_all()
 def on_generic_combobox_changed(self, combobox):
     if self.codBar_combo.get_active() == 0:
         from PrintDialog import PrintDialogHandler
         from  xhtml2pdf import pisa
         f = self.html_code
         g = file(Environment.tempDir + ".temp.pdf", "wb")
         pisa.CreatePDF(str(f), g)
         g .close()
         anag = PrintDialogHandler(self, self.windowTitle)
         anagWindow = anag.getTopLevel()
         returnWindow = self.bodyWidget.getTopLevel().get_toplevel()
         anagWindow.set_transient_for(returnWindow)
         anagWindow.show_all()
         #self.codBar_combo.set_active(0)
     elif self.codBar_combo.get_active() == 1:
         print "ANTEPRIMA CSV"
     else:
         self.codBar_combo.set_active(-1)
    def on_pdf_button_clicked(self, button):
        from PrintDialog import PrintDialogHandler

        operation = Gtk.PrintOperation()
        setting = Gtk.PageSetup()
        ps = Gtk.PaperSize.new_custom("cc", "cc", 210, 297, gtk.Unit.MM)
        st = Gtk.PrintSettings()
        s = Gtk.PageSetup()
        s.set_paper_size(ps)
        margine_fondo = float(setconf("Stampa", "report_margine_basso") or 4.3)
        s.set_bottom_margin(margine_fondo, gtk.Unit.MM)
        margine_sinistro = float(
            setconf("Stampa", "report_margine_sinistro") or 4.3)
        s.set_left_margin(margine_sinistro, gtk.Unit.MM)
        margine_destro = float(
            setconf("Stampa", "report_margine_destro") or 4.3)
        s.set_right_margin(margine_destro, gtk.Unit.MM)
        margine_alto = float(setconf("Stampa", "report_margine_alto") or 4.3)
        s.set_top_margin(margine_alto, gtk.Unit.MM)
        orientamento = str(setconf("Stampa", "report_ori"))
        if not orientamento or orientamento == "orizzontale":
            s.set_orientation(Gtk.PageOrientation.LANDSCAPE)
        operation.set_default_page_setup(s)
        operation.set_export_filename(Environment.tempDir + ".temp.pdf")
        #import xhtml2pdf.pisa as pisa
        #import cStringIO
        #data=  self.print_on_screen_html.get_main_frame().get_data_source().get_data().str
        #g = open(Environment.tempDir + "ciccio.html", "w")
        # pdf = pisa.CreatePDF(
        #     cStringIO.StringIO(data),
        #     g
        # )
        #g.write(data)
        #g.close()
        p = self.print_on_screen_html.get_main_frame().print_full(operation,
                                                      gtk.PrintOperationAction.EXPORT)
        pbar(self.pbar, pulse=True, text="GENERAZIONE STAMPA ATTENDERE")
        pbar(self.pbar, stop=True)
        anag = PrintDialogHandler(self, self.windowTitle, tipo="report")
        anagWindow = anag.getTopLevel()
        returnWindow = self.bodyWidget.getTopLevel().get_toplevel()
        anagWindow.set_transient_for(returnWindow)
        anagWindow.show_all()