Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1681
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Knute Johnson <nospam@knutejohnson.com> |
| Newsgroups | comp.lang.java.help |
| Subject | Re: Addressing the printer -- Newbie |
| Date | Wed, 28 Mar 2012 09:34:36 -0700 |
| Organization | A noiseless patient Spider |
| Lines | 99 |
| Message-ID | <jkveit$lcf$1@dont-email.me> (permalink) |
| References | <4f6fbe47$1@dnews.tpgi.com.au> <jkq5vh$6br$1@dont-email.me> <4f720675@dnews.tpgi.com.au> <4f720bc8$1@dnews.tpgi.com.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Wed, 28 Mar 2012 16:34:37 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="mz/LDSJwiWnk3Jnnqg7x+Q"; logging-data="21903"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LdaaSIIe7ENKU5G+T1wHX" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 |
| In-Reply-To | <4f720bc8$1@dnews.tpgi.com.au> |
| Cancel-Lock | sha1:jdmOd13Hja1MhH2SDElIs5CInt4= |
| Xref | csiph.com comp.lang.java.help:1681 |
Show key headers only | View raw
On 3/27/2012 11:49 AM, blank wrote:
> Most of that was above my head...
>
> I think it might be handy to show an actual example of how I currently print
> hard copy reports using VB6. This is an accounting program. The report in
> question lists particular transactions and shows them in columns. I have cut
> out all the code that does not relate to the printer
>
> Printer.Orientation = vbPRORPortrait
> aPageCount = 0
> aLineCount = 0
> 'Report title and column headers here
> For Looper = 1 to end of file
> 'get data from file here
> Aligned = Format(Looper, "###"): Printer.CurrentX = 20 -
> Printer.TextWidth(Aligned): Printer.Print Aligned;
> Printer.CurrentX = 33: Printer.Print TransactionCode;
> Printer.CurrentX = 48: Printer.Print TransactionDescription
> 'various other columns
> 'testing for page feed here
> aLineCount = aLineCount + 1
> If aLineCount> 56 Then
> Printer.NewPage
> '[Title and column header routine]
> End If
> Next Looper
>
> I am really looking for a simple example, such as how to align coulmns in
> Java and address the connected printer without having to specify it.
>
> "blank"<blank@blankety.blank.com> wrote in message
> news:4f720675@dnews.tpgi.com.au...
>> Thanks for that Knute...
>>
>> Takes me back to my own flying days in the UK in a Cherokee!
>>
>> But what an incredible amount of code when I can address the installed
>> printer with 2 lines of code in VB6!
>>
>> "Knute Johnson"<nospam@knutejohnson.com> wrote in message
>> news:jkq5vh$6br$1@dont-email.me...
>>> On 3/25/2012 5:54 PM, blank wrote:
>>>> Hi all
>>>>
>>>> I am a keen programmer in Visual Basic 6. I also tried Visual Basic
>>>> dot.net
>>>> but was appalled at the lack of printer support in dot.net.
>>>>
>>>> I am thinking of learning Java, but would like to know if the language
>>>> allows easy access to whatever printer is installed at a user site.
>>>> Therefore I cannot specify the printer when writing the code and must
>>>> rely
>>>> on the operating system to route data to the printer.
>>>>
>>>> Is writing reports to the printer (formatted and with columns and so on
>>>> as
>>>> in VB6) practical? With vb6 it is as simple as printer.print!
>>>>
>>>> Thanks heaps
>>>>
>>>>
>>>
>>> For some sample code, look at the VFRFlightLog program here;
>>>
>>> http://rabbitbrush.frazmtn.com/aviation/index.html
>>>
>>> --
>>>
>>> Knute Johnson
>>
>>
>
>
Java doesn't have the ability to print in a "text" mode. The graphic
mode is more complicated but it follows GUI creation and drawing very
closely.
If you have a printer attached directly to your computer you could try
this code;
import java.io.*;
public class test {
public static void main(String[] args) throws Exception {
FileOutputStream fos = new FileOutputStream("LPT1:");
PrintWriter pw = new PrintWriter(fos);
for (int i=0; i<50; i++)
pw.println(i);
pw.close();
}
}
It's not going to work for network attached printers unless you can get
a OS character device for them.
--
Knute Johnson
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar | Unroll thread
Addressing the printer -- Newbie "blank" <blank@blankety.blank.com> - 2012-03-26 11:54 +1100
Re: Addressing the printer -- Newbie "John B. Matthews" <nospam@nospam.invalid> - 2012-03-25 21:01 -0400
Re: Addressing the printer -- Newbie "blank" <blank@blankety.blank.com> - 2012-03-26 15:25 +1100
Re: Addressing the printer -- Newbie "John B. Matthews" <nospam@nospam.invalid> - 2012-03-26 09:24 -0400
Re: Addressing the printer -- Newbie Roedy Green <see_website@mindprod.com.invalid> - 2012-03-25 20:32 -0700
Re: Addressing the printer -- Newbie Knute Johnson <nospam@knutejohnson.com> - 2012-03-26 09:37 -0700
Re: Addressing the printer -- Newbie "blank" <blank@blankety.blank.com> - 2012-03-28 05:26 +1100
Re: Addressing the printer -- Newbie "blank" <blank@blankety.blank.com> - 2012-03-28 05:49 +1100
Re: Addressing the printer -- Newbie Knute Johnson <nospam@knutejohnson.com> - 2012-03-28 09:34 -0700
csiph-web