New topic: Print contents of Canvas
<http://forums.realsoftware.com/viewtopic.php?t=46868> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message torrid Post subject: Print contents of CanvasPosted: Thu Feb 07, 2013 6:29 pm Joined: Sat Jun 04, 2011 8:29 am Posts: 378 I have a canvas I use for a button. In the Paint of the canvas it draws an image as well as text onto the canvas. This all works. Now I need to print a picture of this button. How do I do that? _________________ Currently using: Windows XP Pro SP3 Real Studio 2011 Release 4.3 Enterprise and Mac OS 10.7.4 Real Studio 2011 Release 4.3 Enterprise (finally also compiled on Mac) Top DaveS Post subject: Re: Print contents of CanvasPosted: Thu Feb 07, 2013 7:31 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4506 Location: San Diego, CA ASSUMPTIONS : your picture is called WORK_AREA (change code below as required) method get_rez returns actual maximum resolution of printer various global variables exist option_Printer_FitPage if true will force picture to fit to page option_Printer_Landscape if true will print the picture landscape mode option_Printer_Center .. two values... one for horizontal center, one for vertical center I will leave it up to you to modify to fit you need..... just cut it out of one of my existing apps. oh and you have to supply a global PRINTER_GRAPHICS and PRINTER_SETUP object as well Dim x As Integer Dim y As Integer Dim w As Integer Dim h As Integer Dim pw As Integer Dim ph As Integer Dim aspect As Single Printer_setup=New PrinterSetup printer_setup.SetupString=Printer_SetupString printer_setup.Landscape=option_Printer_Landscape Printer_Setup.maxHorizontalResolution=get_printer_rez(True) Printer_Setup.maxVerticalResolution=get_printer_rez(False) Printer_graphics=OpenPrinterDialog(Printer_Setup) If Printer_Graphics<>Nil Then w=work_area.width h=work_area.height aspect=w/h pw=Printer_graphics.width ph=pw/aspect If ph>Printer_graphics.height Then ph=Printer_graphics.height pw=ph*aspect End If // // Don't make print image any "bigger".... just smaller if necessary // If pw>w And Not option_Printer_FitPage Then pw=w ph=h End If x=0 y=0 If pw<Printer_graphics.width And option_Printer_Center(0) Then x=(Printer_graphics.width-pw)\2 End If If ph<Printer_graphics.height And option_Printer_Center(1) Then y=(Printer_graphics.height-ph)\2 End If Printer_graphics.DrawPicture work_area,x,y,pw,ph,0,0,w,h End If Printer_graphics=Nil Return True _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
