Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1665 > unrolled thread

Addressing the printer -- Newbie

Started by"blank" <blank@blankety.blank.com>
First post2012-03-26 11:54 +1100
Last post2012-03-28 09:34 -0700
Articles 9 — 4 participants

Back to article view | Back to comp.lang.java.help


Contents

  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

#1665 — Addressing the printer -- Newbie

From"blank" <blank@blankety.blank.com>
Date2012-03-26 11:54 +1100
SubjectAddressing the printer -- Newbie
Message-ID<4f6fbe47$1@dnews.tpgi.com.au>
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 

[toc] | [next] | [standalone]


#1666

From"John B. Matthews" <nospam@nospam.invalid>
Date2012-03-25 21:01 -0400
Message-ID<nospam-785D41.21012025032012@news.aioe.org>
In reply to#1665
In article <4f6fbe47$1@dnews.tpgi.com.au>,
 "blank" <blank@blankety.blank.com> wrote:

> 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!

This tutorial maybe a good starting point:

<http://docs.oracle.com/javase/tutorial/2d/printing/index.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

[toc] | [prev] | [next] | [standalone]


#1670

From"blank" <blank@blankety.blank.com>
Date2012-03-26 15:25 +1100
Message-ID<4f6fefb1@dnews.tpgi.com.au>
In reply to#1666
Thanks John

I have looked through that and it does seem so much more complicated than 
Vb6!  I do not want to print a screen but I want to output the results of 
accounting calculations. I also want the program to automatically see 
whatever printer is connected to the user's computer and not bother with the 
dialogue box at all, if possible.

Cheers

"John B. Matthews" <nospam@nospam.invalid> wrote in message 
news:nospam-785D41.21012025032012@news.aioe.org...
> In article <4f6fbe47$1@dnews.tpgi.com.au>,
> "blank" <blank@blankety.blank.com> wrote:
>
>> 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!
>
> This tutorial maybe a good starting point:
>
> <http://docs.oracle.com/javase/tutorial/2d/printing/index.html>
>
> -- 
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews> 

[toc] | [prev] | [next] | [standalone]


#1672

From"John B. Matthews" <nospam@nospam.invalid>
Date2012-03-26 09:24 -0400
Message-ID<nospam-36F0B5.09241226032012@news.aioe.org>
In reply to#1670
In article <4f6fefb1@dnews.tpgi.com.au>,
 "blank" <blank@blankety.blank.com> wrote:

> I have looked through that and it does seem so much more complicated 
> than Vb6!

This is not surprising, as Java printing support is cross-platform.

> I do not want to print a screen but I want to output the results of 
> accounting calculations.

Several related components have extra support in this area:

<http://docs.oracle.com/javase/tutorial/2d/printing/swing.html>

> I also want the program to automatically see whatever printer is 
> connected to the user's computer and not bother with the dialogue box 
> at all, if possible.

Interesting; I almost always choose print to PDF. The dialogs are 
optional, but I never code it that way for myself.

-- 
[Please exclude signatures when replying.]

[toc] | [prev] | [next] | [standalone]


#1669

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-03-25 20:32 -0700
Message-ID<vjovm71815v4kipif5puniouegj1h3p3uv@4ax.com>
In reply to#1665
On Mon, 26 Mar 2012 11:54:26 +1100, "blank" <blank@blankety.blank.com>
wrote, quoted or indirectly quoted someone who said :

>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

Java's idea of printing is essentialy building a virtual screen
display and taking a snapshot of it.  You build it page by page the
same way you build a screen. You don't emit characters in a stream
with embedded control chars the way you did in DOS days.

Java has changed the rules on how printing works a number of times.
See http://mindprod.com/jgloss/printing.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..

[toc] | [prev] | [next] | [standalone]


#1675

FromKnute Johnson <nospam@knutejohnson.com>
Date2012-03-26 09:37 -0700
Message-ID<jkq5vh$6br$1@dont-email.me>
In reply to#1665
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

[toc] | [prev] | [next] | [standalone]


#1679

From"blank" <blank@blankety.blank.com>
Date2012-03-28 05:26 +1100
Message-ID<4f720675@dnews.tpgi.com.au>
In reply to#1675
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 

[toc] | [prev] | [next] | [standalone]


#1680

From"blank" <blank@blankety.blank.com>
Date2012-03-28 05:49 +1100
Message-ID<4f720bc8$1@dnews.tpgi.com.au>
In reply to#1679
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
>
> 

[toc] | [prev] | [next] | [standalone]


#1681

FromKnute Johnson <nospam@knutejohnson.com>
Date2012-03-28 09:34 -0700
Message-ID<jkveit$lcf$1@dont-email.me>
In reply to#1680
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web