-
how to print in Dos Mode and How to change Font Size ?
I wish to dos mode printing to print bills, (Creating Text file to print). How can i change font size ?
I saw following codes in sample for printing dos mode. Please explain usage of following codes
Print #1, Chr(27) 'purpose ?
Print #1, Chr(12) 'purpose ?
Print #1, particulars; Spc(17 - Len(CStr(particulars))); ' purpose ?
Print #1, vbCr ?
How can i set paper size ?
Senthil kumar.A
-
Re: how to print in Dos Mode and How to change Font Size ?
Thread moved from CodeBank forum (which is for you to post your code examples, not questions)
Most of what you want/need (including things you haven't thought of yet) is explained by this tutorial, which is listed in the Printing section of our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)
-
Re: how to print in Dos Mode and How to change Font Size ?
Thats not really DOS mode as that would imply printing from a DOS console window. :)
-
Re: how to print in Dos Mode and How to change Font Size ?
Sir, I put sample codes to know the usage these codes . Please explain me usage of these codes
-
Re: how to print in Dos Mode and How to change Font Size ?
did you read the links Si posted?
The help file has documentation on the Chr function which uses the ASCII character code value. Just press F1 to bring up your help files inside of your VB.
-
Re: how to print in Dos Mode and How to change Font Size ?
the sample code you posted at the top looks more like code to write a text file, i guess then that the finished text file is sent to the printer, using the dos copy (filename lpt1:) or print commands
this will only work to a parallel printer (or redirected serial printer), but not to a USB or network printer
sending chr(27) is the escape command to tell the printer that the next character(s) are printer commands, the ctrl L (12) is the next character, can't think want ctrl L does at the moment, the third line is the string variables to be printed, in this case variable particulars and a series of spaces, vbCr is carriage return or new line
as most of us no longer use parallel printers it is hard to test code etc for dos mode printers
to set page sizes read your printer manual, as i don't remember specific codes to set page sizes and anyway they vary from printer to printer
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Originally Posted by westconn1
the sample code you posted at the top looks more like code to write a text file, i guess then that the finished text file is sent to the printer, using the dos copy (filename lpt1:) or print commands
this will only work to a parallel printer (or redirected serial printer), but not to a USB or network printer
sending chr(27) is the escape command to tell the printer that the next character(s) are printer commands, the ctrl L (12) is the next character, can't think want ctrl L does at the moment, the third line is the string variables to be printed, in this case variable particulars and a series of spaces, vbCr is carriage return or new line
as most of us no longer use parallel printers it is hard to test code etc for dos mode printers
to set page sizes read your printer manual, as i don't remember specific codes to set page sizes and anyway they vary from printer to printer
under properties for that printer, you can assign it a port to use. Even network printers can be assigned a serial or parallel emulated port.
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
under properties for that printer, you can assign it a port to use. Even network printers can be assigned a serial or parallel emulated port.
ok i am interested in how to do that, can you give more detail, if i change the port for my network printer nothing will print at all
-
Re: how to print in Dos Mode and How to change Font Size ?
unfortunately i can't step you through this. I don't have a printer any more. But right click on your printer icon. It is in there somewhere.
-
Re: how to print in Dos Mode and How to change Font Size ?
yeah, i know how to change the port, but that does not mean i can use the printer from dos mode
-
Re: how to print in Dos Mode and How to change Font Size ?
i didn't say anything about CHANGING anything. I said you can give it another one. It assigns new ports for you. Where are you getting DOS mode at? You running windows 98?
Ok i booted up my wife's system and went through the steps.
Step 1: right click on printer, click properties
click the ports tab
assign the printer one of the lpt ports (remember which one)
from a command prompt, test it like this:
type "test output" -> lpt1
replace the 1 with whatever number you chose.
-
Re: how to print in Dos Mode and How to change Font Size ?
i did all that before, just returned invalid port message (which makes sense, no lpt1 port), i will try again on another computer later
thanks for trying i would like to follow this up, not quite sure why and it would not work in real dos anyway, only windows dosbox
-
Re: how to print in Dos Mode and How to change Font Size ?
and where exactly would you be running REAL dos? Real dos won't even read your NTFS hard drive. If you have programs that require dos, run DOSBOX (open-source). I left out something: There's also an option on there "usb port emulation" in the same list. You have to have it checked as well before you add the lpt port.
-
Re: how to print in Dos Mode and How to change Font Size ?
You can map printers via NET USE as described in http://support.microsoft.com/kb/314499 as well.
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Originally Posted by imagetvr
I wish to dos mode printing to print bills, (Creating Text file to print). How can i change font size ?
I saw following codes in sample for printing dos mode. Please explain usage of following codes
Print #1, Chr(27) 'purpose ?
Print #1, Chr(12) 'purpose ?
Print #1, particulars; Spc(17 - Len(CStr(particulars))); ' purpose ?
Print #1, vbCr ?
How can i set paper size ?
Senthil kumar.A
Chr(12) sends a Page break / New Page to the Printer
Print #1, particulars; Spc(17 - Len(CStr(particulars)));
Prints the contents of the variable "particulars" and prints as many spaces
as is required to move the carraige to the 18th paosition.
Print #1, vbCr ?
Sends a Carriage Return to the Printer.
-
Re: how to print in Dos Mode and How to change Font Size ?
actually those are file commands, not printer, but the rest of it's accurate.
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Originally Posted by Lord Orwell
actually those are file commands, not printer, but the rest of it's accurate.
Yes you are right. My reply was a bit misleading. Sorry.
What I meant is, when you print the file, the printer responds in such and such manner.
-
Re: how to print in Dos Mode and How to change Font Size ?
i don't remember what it's called, but some printers use a standard set of controls for custom stuff such as font sizes, etc. This is how linux is able to use generic printer drivers for some models of printers. If you were to search linux forums for your printer, you might hit the jackpot.
-
Re: how to print in Dos Mode and How to change Font Size ?
Thanks MR SVG3414
Your reply is useful for me. Please give me idea, if possible code for
1. Changing font and font size
2.and alignment of numbers
I wish to align right justified ie
22.50
100.00
1522.00 like that please help me
Thanks
senthil kumar
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Please give me idea, if possible code for
1. Changing font and font size
If you are printing to a .txt file, you can't - you would need to use different code, such as using the Printer (like in the tutorial I linked to), or using a different file type (which would probably be much more complex).
Quote:
2.and alignment of numbers
You need to use either:
- a fixed-width font (see answer to 1), and a particular amount of spaces.
- specify the position based on the TextWidth (requires the Printer object, see the tutorial I linked to for example code for this)
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Originally Posted by imagetvr
Thanks MR SVG3414
Your reply is useful for me. Please give me idea, if possible code for
1. Changing font and font size
2.and alignment of numbers
I wish to align right justified ie
22.50
100.00
1522.00 like that please help me
Thanks
senthil kumar
1. Regarding font size i will inform ASAP.
2. Suppose your number is stored in a variable named num.
print #1, format(format(num, "fixed"),"@@@@@@@@@@@@@@@")
will right align to the 15th position with 2 decimal places.
Hope you get the idea.
-
Re: how to print in Dos Mode and How to change Font Size ?
this is what i was referring to. You can't have a standard text file with formatting to change the font size. You need to either print in graphics mode by printing a bitmap file, or you need to print directly to the printer and use the brand-specific control codes, or you need to use a filetype that allows you to change font sizes, such as .rtf. This is actually not that difficult since the richedit control supports this, as well as allowing you to print directly.
-
Re: how to print in Dos Mode and How to change Font Size ?
These should work on most DMPs especially EPSON ones.
Basically there are 3 font sizes built into the printer firmware.
1) Normal size
2) Large size - Use chr(14)
Eg; Print #1, chr(14); "ABCDE"
Will print ABCDE in large sized font. To revert back to normal size you can use chr(18)
Eg; Print #1, chr(14); "ABCDE"; chr(18); "XYZ"
Will print ABCDE in large sized font and XYZ in normal sized font.
3) Condensed - Use chr(15)
Eg; Print #1, chr(15); "ABCDE"
Will print ABCDE in condensed font. To revert back to normal size you can use chr(18)
Eg; Print #1, chr(15); "ABCDE"; chr(18); "XYZ"
Will print ABCDE in condensed font and XYZ in normal sized font.
This is all that I know.
Regarding pagesize, there are specific codes. These may be found in the Printer manual.
As far as I am concerned, in the progrmme I count the number of lines and send a page eject (chr(12)) when required. For example if the length of paper is 12" and you are printing @ 6 lines per inch with 1" margin on top and bottom, you can print 60 line on a sheet. After 60 lines you give a page eject to start the new page.
-
Re: how to print in Dos Mode and How to change Font Size ?
Hello Mr. SVG
Thanks for your very detailed reply. Your reply very much helpful to me, I once again thanks for your reply.
Again i have i doubt
1. How can i give blank line between lines ? (IF i need one blank line)
2. Suppose my paper width is 9 inches, How many characters to be printed in one line ? (horizontal line)
Once again thankful to you
-
Re: how to print in Dos Mode and How to change Font Size ?
Quote:
Originally Posted by imagetvr
Hello Mr. SVG
Thanks for your very detailed reply. Your reply very much helpful to me, I once again thanks for your reply.
Again i have i doubt
1. How can i give blank line between lines ? (IF i need one blank line)
2. Suppose my paper width is 9 inches, How many characters to be printed in one line ? (horizontal line)
Once again thankful to you
1. Print #1, vbnewline
2. Depends on the font size. Normally it is 10 cpi. So after leaving 1 inch margin on left and right it will be 7*10 = 70 characters.