New topic: 

Print Preview with graphics and styledtext

<http://forums.realsoftware.com/viewtopic.php?t=29502>

       Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic         Author  
Message       dagipper           Post subject: Print Preview with graphics and 
styledtextPosted: Tue Aug 11, 2009 12:50 pm                        
Joined: Sat Jul 19, 2008 6:52 am
Posts: 6              Hello, I can print out a page with using a combination of 
graphics (drawstring, drawrect, etc...) and styledtext and I can print a 
preview of a canvas with only graphics (drawstring, drawrect, ect...).  
However, can someone point me in the right direction as to how I can view a 
print preview page showing both graphics and styledtext.  Is it even possible?  

Background:  I am trying to figure out the easiest way to center text into a 
column or box.  I discovered that I can do this without much code using 
styledtextprinter. I can draw a box on the screen  with a drawrect and I 
perfectly center the text in the box with the styledtextprinter feature.  I can 
print a page using these two features together.  However, using a canvas, I can 
only show the graphics (drawstring, and drawrect), I cannot figure out how I 
can show the styledtext as well.  

Thank you in advance for all your time and help!   
                            Top                timhare           Post subject: 
Re: Print Preview with graphics and styledtextPosted: Tue Aug 11, 2009 1:13 pm  
                      
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 6069
Location: Portland, OR  USA              A StyledTextPrinter operates on a 
Graphics object.  Whether that graphics object comes from the printer or from a 
preview canvas, it doesn't care.  You should be able to use the exact same code 
to print or preview and simply pass it the appropriate graphics object (printer 
or canvas).

In other words, you're using the correct approach, and something is wrong with 
your code. You'll have to post something for us to look at.

Tim   
                            Top               dagipper           Post subject: 
Re: Print Preview with graphics and styledtextPosted: Tue Aug 11, 2009 2:50 pm  
                      
Joined: Sat Jul 19, 2008 6:52 am
Posts: 6              Thank you Tim for your reply.  

I'll take a easy example from the language reference.

Here is the code:


Dim stp as StyledTextPrinter
Dim g as Graphics
g=OpenPrinterDialog()

If g <> Nil then
stp=TextArea1.StyledTextPrinter(g,72*7.5)
stp.DrawBlock 0,0,72*10

End if
 
Let's say if I press the print button, I will print the textarea1 styled text.  
Using this code how can I write this to a canvas named canvas1?


Thanks again!   
                            Top                timhare           Post subject: 
Re: Print Preview with graphics and styledtextPosted: Tue Aug 11, 2009 3:03 pm  
                      
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 6069
Location: Portland, OR  USA              You would replace
Code:g=OpenPrinterDialog()
with
Code:g = Canvas1.Graphics
or possibly
Code:dim pic as New Picture(Canvas1.Width, Canvas1.Height, 32)
g = pic.Graphics
..
Canvas1.BackDrop =  pic


However, your post seemed to indicate that you knew this already, had tried it, 
and it didn't work.  Is that not the case?

Tim   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 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

rbforumnotifier@monkeybreadsoftware.de

Reply via email to