Printing to my Printer
#11
Thanks a lot bplus. I'm now printing in color but I am puzzled about why the screen size matters? It seemed that the coding at the very beginning was setting up the scaling factor to convert what ever screen size you had to standard page size in a printer. If the following code from the wiki on _Printimage, isn't scaling what's on the screen for a standard page in a printer what exactly is it for?

Page Scale = 2
PageHeight = 297 * PageScale
PageWidth = 210 * PageScale
Page&= _NewImage(PageWidth, PageHeight,32)
Reply
#12
I recently had occasion to print multiple pages of text from a harvest truck load database. The setup was fairly straightforward.

    DO
        pn% = pn% + 1
        REDIM _PRESERVE pg(pn%) AS LONG
        pg(pn%) = _NEWIMAGE(640, 900, 32)
        _DEST pg(pn%)
        COLOR &HFF000000, _RGB32(255)
        CLS

        'then do the line by line stuff with a for-next loop to control row LOCATE and then setting an alldone% flag when finished
        'other code with in the for-next loop to control when a page breaks

    LOOP UNTIL alldone%

The 640 x 900 yields a precise 80 column by 56 row relationship.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Reply
#13
Thanks OldMoses I'll give it a try. Prefer not to file _Putimage , as suggested, at this time.
Reply
#14
Quote:In QB64 LPRINT detects USB printers. It says on the Wiki help page. I'm not sure about LPRINT USING https://qb64phoenix.com/qb64wiki/index.php/LPRINT


So, "LPrint Using" doesn't understand QB64, but it works with "LPrint". But I can't say at the moment whether it will also be printed out formatted, because the ink is gone.

Code: (Select All)
LPrint "####.##", 29.99
Reply
#15
It's a question of do you want to print text ?or do you want an image similar to the one you've drawn on screen?

If you want to print text why not use your favorite text editor that has been professionally designed for the job with all kinds of bells and whistles.

For images you've got printed / drawn on screen, what I had assumed Dimster was after, use page dimensions similar to screen or do the math and turn the page sideways with a little more complex _putimage or rotozoom command. BTW another _PutImage option is draw the printer page exactly in proportion to screen 1 pixel for 1 pixel and leave probably the lower half of printed page blank, or center it on printed page. It's not like you don't have plenty of options with _putimage or rotozoom.

Print Text? or Print Image (of Text Plus...)?
b = b + ...
Reply
#16
Give this a try:

Code: (Select All)
'How to properly _PRINTIMAGE a screen of text
'by Steve!

$Color:32
Const scale = 80


Screen _NewImage(7.5 * scale, 10 * scale, 32) 'standard printer paper is 8.5 x 11 inches, with .5 margins.
'                                                This gives us a 7.5 x 10 inch print area.
'                                                Scale here is used so we can set this to a proper size for our PC display
'                                                In this case, I'm going with a 600 x 800 screen size.
'                                               Notice in most cases, this is a simple 3:4 width:height ratio!

Cls , White '                                   Set the screen to being a white color, so that you won't print your page in black.
Color Black '                                   Set the text to Black so that it'll show up on the screen as you desire.
_PrintMode _KeepBackground '                    And either set the color with a transparent background, a white background,
'                                                or use printmode so you're not printing Black on the default Black background.


Print "This screen is"; 7.5 * scale; "pixels wide, and"; 10 * scale; "pixels high."
Print
Print "Also notice that I've colored the background white, and the text black."
Print
Print "And this is honestly all I need to do to set up a page for proper printing with _PRINTIMAGE."
Print
Print "Press <ANY KEY> to see for yourself!"
Sleep

_PrintImage 0 'the 0 here says to print the active/visual screen image.


For me, this will open a text dialog and print me a PDF file as I have "Microsoft Print to PDF" set as my default printer.  If your physical printer is set as the default output, then you can use this to print directly to it instead.  If you need to choose between printer outputs, then you have a lot more code to write to interface with the printer management interface used by your OS, but if you just want to print to your default printer, this is all you really need to do for it.
Reply
#17
It works great Steve, thanks for same.

I did not appreciate the difference between Text on a screen and an Image on a screen. I thought the wiki was providing a screen dump no matter what was on the screen. That, no matter what the dimensions of the screen I was using, the program simply scaled to printer paper size and printed it. The larger the screen (2000,1000,32), the smaller the print would look on the printer paper. 

Live and learn, live and learn and never ever think you know it all. Thanks again
Reply
#18
We do scale to paper size; the problem is your aspect ratio.

Your 2000x1000 screen is on a 2:1 ratio, while paper is closer to a 3:4 ratio. You're going to distort the bejeebers out of whatever you're trying to print at that scale!

When I need to print, I've always just found it easiest to set my screen size to the same ratio as my paper size, and then things will look the same on the paper as they do on the screen. Wink
Reply




Users browsing this thread: 1 Guest(s)