Beispiel #1
0
 def print_view(self, page_setup, prompt=True):
     paginator = Paginator(self, page_setup)
     psd = page_setup._win_psd
     pd = wp.PRINTDLG()
     pd.hDevMode = psd.hDevMode
     pd.hDevNames = psd.hDevNames
     pd.nMinPage = 1
     pd.nMaxPage = paginator.num_pages
     pd.nCopies = 1
     if wp.PrintDlg(pd):
         title = self.print_title
         di = wp.DOCINFO()
         di.lpszDocName = title
         devnames = wps.DevNames(psd.hDevNames)
         if devnames.output == "FILE:":
             from FileDialogs import request_new_file
             f = request_new_file("Print '%s' to file:" % title)
             if not f:
                 return
             output_path = f.path
             di.lpszOutput = output_path
         try:
             hdc = pd.hDC
             dx, dy = wp.GetPrintingOffset(hdc)
             print "TODO: Printable: Implement a Cancel dialog"  ###
             #wp.install_abort_proc(hdc)
             wp.StartDoc(hdc, di)
             for page_num in xrange(pd.nFromPage - 1, pd.nToPage):
                 wp.StartPage(hdc)
                 canvas = Canvas._from_win_hdc(hdc, for_printing=True)
                 canvas.translate(-dx, -dy)
                 paginator.draw_page(canvas, page_num)
                 wp.EndPage(hdc)
             wp.EndDoc(hdc)
         finally:
             wp.DeleteDC(hdc)
 def print_view(self, page_setup, prompt = True):
     paginator = Paginator(self, page_setup)
     psd = page_setup._win_psd
     pd = wp.PRINTDLG()
     pd.hDevMode = psd.hDevMode
     pd.hDevNames = psd.hDevNames
     pd.nMinPage = 1
     pd.nMaxPage = paginator.num_pages
     pd.nCopies = 1
     if wp.PrintDlg(pd):
         title = self.print_title
         di = wp.DOCINFO()
         di.lpszDocName = title
         devnames = wps.DevNames(psd.hDevNames)
         if devnames.output == "FILE:":
             from FileDialogs import request_new_file
             f = request_new_file("Print '%s' to file:" % title)
             if not f:
                 return
             output_path = f.path
             di.lpszOutput = output_path
         try:
             hdc = pd.hDC
             dx, dy = wp.GetPrintingOffset(hdc)
             print "TODO: Printable: Implement a Cancel dialog" ###
             #wp.install_abort_proc(hdc)
             wp.StartDoc(hdc, di)
             for page_num in xrange(pd.nFromPage - 1, pd.nToPage):
                 wp.StartPage(hdc)
                 canvas = Canvas._from_win_hdc(hdc, for_printing = True)
                 canvas.translate(-dx, -dy)
                 paginator.draw_page(canvas, page_num)
                 wp.EndPage(hdc)
             wp.EndDoc(hdc)
         finally:
             wp.DeleteDC(hdc)
Beispiel #3
0
 def print_view(self, page_setup, prompt = True):
     global gtk_print_settings
     paginator = Paginator(self, page_setup)
     
     def draw_page(_, gtk_print_context, page_num):
         cairo_context = gtk_print_context.get_cairo_context()
         canvas = Canvas._from_cairo_context(cairo_context)
         paginator.draw_page(canvas, page_num)
     
     gtk_op = gtk.PrintOperation()
     gtk_op.set_print_settings(gtk_print_settings)
     gtk_op.set_default_page_setup(page_setup._gtk_page_setup)
     gtk_op.set_n_pages(paginator.num_pages)
     gtk_op.set_use_full_page(True)
     gtk_op.set_unit(UNIT_POINTS)
     gtk_op.connect('draw-page', draw_page)
     if prompt:
         action = gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG
     else:
         action = gtk.PRINT_OPERATION_ACTION_PRINT
     result = gtk_op.run(action)
     if result == gtk.PRINT_OPERATION_RESULT_APPLY:
         gtk_print_settings = gtk_op.get_print_settings()