Author Topic: Printing to a Dot Matrix printer (Generic/Text)  (Read 2831 times)

0 Members and 1 Guest are viewing this topic.

Offline tschwan

  • Newbie
  • Posts: 1
    • View Profile
Printing to a Dot Matrix printer (Generic/Text)
« on: September 20, 2019, 11:00:41 am »
I have an application that prints text onto pre-printed, multi-part forms using a dot matrix printer. I have loaded the app into QB64 for testing and have found that the text does print to a laser printer but the printing is painfully S L O W. In the Windows Print Manager the size of the printed pages is quite large for 'text' (e.g. @19 MB). I setup a Generic/Text printer pointing to the Laser, set as the default, and now the pages do print very fast but they are all blank. Does QB64  need to have some default printing parameters setup in the program? In DOS I just pointed to LPT1: and life was good. Any suggestions are appreciated.

Thanks,
Ted

  [ You are not allowed to view this attachment ]  

Offline MWheatley

  • Newbie
  • Posts: 64
    • View Profile
Re: Printing to a Dot Matrix printer (Generic/Text)
« Reply #1 on: September 20, 2019, 12:02:34 pm »
Ted,

To the best of my knowledge, the Generic/ Text printer is a dot matrix printer.  So it sounds like you are printing to a laser printer using a dot matrix printer driver.

Why not select a laser printer driver instead?

Apologies if I've got the wrong end of the stick, here.

Malcolm

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Printing to a Dot Matrix printer (Generic/Text)
« Reply #2 on: September 20, 2019, 01:24:38 pm »

Hello. I don't use LPRINT for printing. I'm using _PRINTIMAGE. It's easier to work with. In addition, some LPRINT escape codes do not work correctly under QB64. To use LPRINT, the printer must be set as Windows default and must be LPT or USB.

Copyed from Help:

There are some Windows command line statements that allow one to (i) identify the current Windows default printer (as well as other printers associated with a PC) and (ii) change the default to a different printer.
A program can use SHELL statements in QB64 to execute those operating system commands. See the following examples provided by forum member DonW:
Contents

 This code issues the command to display a PC's list of printers and routes the output to a text file:

SHELL _HIDE "CMD /C" + "wmic printer get name,default > default.txt"

A sample of the contents of the resulting file is as follows. Notice that the default printer is listed as "TRUE":
Default  Name                           
  FALSE    Microsoft XPS Document Writer
  TRUE     HP Photosmart C7200 series     
  FALSE    HP Officejet Pro 8600         
  FALSE    Fax

 Here is the code to set the default printer to the "HP Officejet Pro 8600" listed in the sample above:


SHELL _HIDE "CMD /C" + "wmic printer where name='HP Officejet Pro 8600' call setdefaultprinter"

Then running the get default SHELL code again, we see the following contents of the text file:
Default  Name                           
  FALSE    Microsoft XPS Document Writer
  FALSE    HP Photosmart C7200 series     
  TRUE     HP Officejet Pro 8600         
  FALSE    Fax

Now we see that the "HP Officejet Pro 8600" is marked as "TRUE", and thus is now the default printer for LPRINT and _PRINTIMAGE.


Example with _PRINTIMAGE:

Code: QB64: [Select]
  1. PrintImage = _NEWIMAGE(210 * 3, 297 * 3, 32) 'A4 paper size is 210x297, for smoother output i set virtual screen 3x biggest
  2. _DEST PrintImage 'all graphic operations are now created on this unvisible screen
  3. CLS , _RGB32(255) 'clear with white color
  4. 'now your code:
  5. text$ = "This is printed"
  6. COLOR _RGB32(0), _RGB32(255) 'black text on white background
  7. PRINT text$
  8. _PUTIMAGE (300, 300)-(600, 600), _SCREENIMAGE 'Print current screen to paper (place it as image to virtual screen and then is printed), SCREENIMAGE works under Windows only
  9.  
  10. 'show you, what is ready for printing
  11. SCREEN PrintImage
  12. 'and print it
  13. _PRINTIMAGE PrintImage
  14.  
  15.