You can always try my ImagePrintWin module for printing - it should be pretty easy to use, and has everything down to a printer setup GUI including print preview. Documentation is in the code, including the test at the very bottom.
http://www.cazabon.com/python/downloads/ImagePrintWin.py Kevin. ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Sunday, November 27, 2005 10:54 PM Subject: [Image-SIG] (no subject) > Hi all, > > Ive been working on a project which uses blender, python and pil but due to > restrictions in the current version of blender ive had to revert to an older > version[2.25] this means older python and older pil. Im now using python 2.0 > and PIL 1.1.1. > ive been changing my scripts so that they work with these other versions but am > runnig into problems with PIL, basically in my project blender takes a > screenshot wihch PIL then prints on the default printer, this used to work fine > but with the older PIL all i get is a page full of black where the image should > be. If any of you who have any knowledge of old versions of PIL could help me > that would be great, below is the script:(which i stole from the internet > somewhere) > > ######################################################################## > if own.printer == 1: > import win32print > import win32ui > from PIL import Image, ImageWin > > import Rasterizer > file_name = "test_a%04d.jpg" % own.printer_count > #####filename = "anim%04d.tga" % obj.frame > Rasterizer.makeScreenshot(file_name) > > # > # Constants for GetDeviceCaps > # > # > # HORZRES / VERTRES = printable area > # > HORZRES = 8 > VERTRES = 10 > # > # LOGPIXELS = dots per inch > # > LOGPIXELSX = 88 > LOGPIXELSY = 90 > # > # PHYSICALWIDTH/HEIGHT = total area > # > PHYSICALWIDTH = 110 > PHYSICALHEIGHT = 111 > # > # PHYSICALOFFSETX/Y = left / top margin > # > PHYSICALOFFSETX = 112 > PHYSICALOFFSETY = 113 > > printer_name = win32print.GetDefaultPrinter () > ####file_name = "test.jpg" > > # > # You can only write a Device-independent bitmap > # directly to a Windows device context; therefore > # we need (for ease) to use the Python Imaging > # Library to manipulate the image. > # > # Create a device context from a named printer > # and assess the printable size of the paper. > # > hDC = win32ui.CreateDC () > hDC.CreatePrinterDC (printer_name) > printable_area = hDC.GetDeviceCaps (HORZRES), hDC.GetDeviceCaps (VERTRES) > printer_size = hDC.GetDeviceCaps (PHYSICALWIDTH), hDC.GetDeviceCaps > (PHYSICALHEIGHT) > printer_margins = hDC.GetDeviceCaps (PHYSICALOFFSETX), hDC.GetDeviceCaps > (PHYSICALOFFSETY) > > # > # Open the image, rotate it if it's wider than > # it is high, and work out how much to multiply > # each pixel by to get it as big as possible on > # the page without distorting. > # > bmp = Image.open (file_name) > if bmp.size[0] > bmp.size[1]: > bmp = bmp.rotate (90) > ratios = [1.0 * printable_area[0] / bmp.size[0], 1.0 * printable_area[1] / > bmp.size[1]] > scale = min (ratios) > > # > # Start the print job, and draw the bitmap to > # the printer device at the scaled size. > # > hDC.StartDoc (file_name) > hDC.StartPage () > > dib = ImageWin.Dib (bmp) > scaled_size = tuple ([scale * i for i in bmp.size]) > x = (printer_size[0] - scaled_size[0]) / 2 > y = (printer_size[1] - scaled_size[1]) / 2 > dib.draw (hDC.GetHandleOutput (), (x, y) + scaled_size) > > hDC.EndPage () > hDC.EndDoc () > > own.printer_count +=1 > own.printer=0 > > ########################################################################## > ive had to change > > dib = ImageWin.Dib (bmp) > > to > > dib = ImageWin.Dib (bmp,(1,1)) > > > Any help would be greatly appreciated > > Thanks > > Will Hurt > > _______________________________________________ > Image-SIG maillist - [email protected] > http://mail.python.org/mailman/listinfo/image-sig > > > _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
