Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Steve's Lesson on Preparing for _PrintImage
#1
Code: (Select All)
$Color:32
_Title "Steve's Lesson on Preparing for _PRINTIMAGE"


ScaleFactor = 0.75 'to whatever suits your screen the best.
ScreenWidth = (850 - 50) * ScaleFactor 'printer paper comes in 8.5 x 11 inches.  Keep your screen in proper scale for it.
ScreenHeight = (1100 - 50) * ScaleFactor 'The minus 50 is for a 25 pixel printer border size along each edge.  Important for some printers.
LeftSizeL = (100 * ScaleFactor) \ _FontWidth + 1 'from experience, always leave an extra 100 pixels or so for hole punching to put print outs in a binder, if needed.
LeftSide = (LeftSizeL - 1) * _FontWidth 'for pixel coordinates instead of locate position
Screen _NewImage(ScreenWidth, ScreenHeight, 32)

Dim ScreenColor(-1 To 0) As _Unsigned Long
ScreenColor(-1) = White: ScreenColor(0) = Black
CurrentBackGround = 0 'Set to your default background color.  -1 for white, 0 for black

Cls , ScreenColor(CurrentBackGround)
Color ScreenColor(Not CurrentBackGround), ScreenColor(CurrentBackGround)

_PrintString (LeftSide, 0), "Seems like a lot to just set up your screen!"
Locate 2, LeftSizeL: Print "So why would I go through all the trouble like this?"
Locate 4, LeftSizeL: Print "Press <ANY KEY> for a quick swap!"
Sleep

CurrentBackGround = -1
Cls , ScreenColor(CurrentBackGround)
Color ScreenColor(Not CurrentBackGround), ScreenColor(CurrentBackGround)

_PrintString (LeftSide, 0), "Seems like a lot to just set up your screen!"
Locate 2, LeftSizeL: Print "So why would I go through all the trouble like this?"
Locate 4, LeftSizeL: Print "Press <ANY KEY> for a quick swap!"
Sleep

CurrentBackGround = 0
Cls , ScreenColor(CurrentBackGround)
Color ScreenColor(Not CurrentBackGround), ScreenColor(CurrentBackGround)

Locate , LeftSizeL: Print "So why would I set things up to quickly toggle between"
Locate , LeftSizeL: Print "black/white and white/black?"
Print
Locate , LeftSizeL: Print "For when I need to PRINT out my logs to a hard copy!"

Print
Print "(and skipping my professional formatting and all from here on, just for ease and speed of writing the rest of the explaination for all this effort...)"
Print
Print "Why did I choose this screen size?"
Print "Because paper comes in 8.5 x 11 inch sheets.  At this point I'm scaling for a nice paper printout at some point in the future with _PRINTIMAGE."
Print
Print "And why did I choose my colors as I have?"
Print "So I can toggle quickly between putting text to the monitor in white on black as we're used to, and then swapping to black on white, which is what printed text looks like."
Print
Print "And why am I saving a left margin so religiously on my page?"
Print "Not all printers reserve a pixel border.  Sure, I subtracted for one from the start, but some of the newer inkjet printers and all go from edge to edge of the page..."
Print "They'll just scale what we have here a wee bit more than border-reserved printers would, but the text would go from edge to edge when they're finsihed."
Print
Print "That's not acceptable.  The reason why I'm preserving that left edge so strictly??"
Print "So I can use a hole punch later with my printout and put my document inside a binder for a hardcopy!"
Print
Print
Print "And that's basically Steve's Lesson of Preparing for _PRINTIMAGE!"


Different people ask about how to get text and such on the screen to come out and look proper with _PRINTIMAGE.  The above is generally the set up that I tend to use (though I'd often write several helper SUBs and FUNCTIONs to let them do the proper formatting so I don't have to keep typing LOCATE , LeftSideL: PRINT "" every time I want to print out to the screen...)

Step 1: Set your screen resolution to match the ratio of a page of paper.  If your printer requires a border, subtract and account for that as well.
Step 2: If what you're printing needs to be preserved in a binder or such, preserve room for the hole punch to do its job without destroying your writing.  All you need to do is have a hole punched once, removing several letters from a vital password, check sum, or credential, and you'll quickly learn why this is so important.
Step 3: Either set your screen to printing black on white by default, or else set up a quick toggle system such as the above.  (Of course, the above is using some long and descriptive variable names which require a lot of typing...  Let's be honest:  either I would write a sub to handle this color inversion normally, or else my variable names would probably just become initials and much easier to type.  Go with what suits you and your coding style the best.)

And with these steps basically in place, you're now set up to make a pretty little page which will print out and look almost exactly the same on your printer as it does on your monitor.  Smile
Reply




Users browsing this thread: 2 Guest(s)