Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Multiple Line output using Win32::Printer

Reply
Thread Tools

Multiple Line output using Win32::Printer

 
 
Jack D
Guest
Posts: n/a
 
      06-08-2006
I'm trying to output mutilple lines to a printer using Win32:rinter. I
have only suceeded in printing one line so far. Does anyone know how force
it to print multiple lines? The output is shows rectangles in between each
word.

Sample code below

use strict;
use Win32:rinter;
my @array = keys %ENV;

printMultiple();

sub printMultiple {
my $dc = new Win32:rinter( papersize => A4,
description => 'Test,
unit => 'mm') or die "Failed to
create printer object";
if ($dc) {
my $textToPrint = join("\r\n",@oldarray);
my $font = $dc->Font('Times New Roman', 12);
$dc->Font($font);
$dc->Color(0, 0, 0);
$dc->Write($textToPrint, 10, 10);
$dc->Close;
}
}
__END__

Jack


 
Reply With Quote
 
 
 
 
Jack D
Guest
Posts: n/a
 
      06-08-2006

"Jack D" <(E-Mail Removed)> wrote in message
news:zmShg.25618$S61.24326@edtnps90...
> I'm trying to output mutilple lines to a printer using Win32:rinter. I
> have only suceeded in printing one line so far. Does anyone know how force
> it to print multiple lines? The output is shows rectangles in between each
> word.
>
> Sample code below
>
> use strict;
> use Win32:rinter;
> my @array = keys %ENV;
>
> printMultiple();
>
> sub printMultiple {
> my $dc = new Win32:rinter( papersize => A4,
> description => 'Test,
> unit => 'mm') or die "Failed to
> create printer object";
> if ($dc) {
> my $textToPrint = join("\r\n",@oldarray);


Oops - this should be
my $textToPrint = join("\r\n",@array);
but it still doesn't work.

> my $font = $dc->Font('Times New Roman', 12);
> $dc->Font($font);
> $dc->Color(0, 0, 0);
> $dc->Write($textToPrint, 10, 10);
> $dc->Close;
> }
> }
> __END__
>
> Jack
>
>



 
Reply With Quote
 
 
 
 
l v
Guest
Posts: n/a
 
      06-08-2006
Jack D wrote:
> I'm trying to output mutilple lines to a printer using Win32:rinter. I
> have only suceeded in printing one line so far. Does anyone know how force
> it to print multiple lines? The output is shows rectangles in between each
> word.
>
> Sample code below
>
> use strict;
> use Win32:rinter;
> my @array = keys %ENV;
>
> printMultiple();
>
> sub printMultiple {
> my $dc = new Win32:rinter( papersize => A4,
> description => 'Test,
> unit => 'mm') or die "Failed to
> create printer object";
> if ($dc) {
> my $textToPrint = join("\r\n",@oldarray);
> my $font = $dc->Font('Times New Roman', 12);
> $dc->Font($font);
> $dc->Color(0, 0, 0);
> $dc->Write($textToPrint, 10, 10);
> $dc->Close;
> }
> }
> __END__
>
> Jack
>
>


What does you print show when you change the "\r\n" in the join to ':'?
my $textToPrint = join(':',@oldarray);

--

Len

 
Reply With Quote
 
Jack D
Guest
Posts: n/a
 
      06-08-2006

"l v" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Jack D wrote:
> > I'm trying to output mutilple lines to a printer using Win32:rinter. I
> > have only suceeded in printing one line so far. Does anyone know how

force
> > it to print multiple lines? The output is shows rectangles in between

each
> > word.
> >
> > Sample code below
> >
> > use strict;
> > use Win32:rinter;
> > my @array = keys %ENV;
> >
> > printMultiple();
> >
> > sub printMultiple {
> > my $dc = new Win32:rinter( papersize => A4,
> > description => 'Test,
> > unit => 'mm') or die "Failed

to
> > create printer object";
> > if ($dc) {
> > my $textToPrint = join("\r\n",@oldarray);
> > my $font = $dc->Font('Times New Roman', 12);
> > $dc->Font($font);
> > $dc->Color(0, 0, 0);
> > $dc->Write($textToPrint, 10, 10);
> > $dc->Close;
> > }
> > }
> > __END__
> >
> > Jack
> >
> >

>
> What does you print show when you change the "\r\n" in the join to ':'?
> my $textToPrint = join(':',@oldarray);


Is this a trick question? It prints the colon of course.

Jack


 
Reply With Quote
 
l v
Guest
Posts: n/a
 
      06-09-2006
Jack D wrote:
> "l v" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>
>>Jack D wrote:
>>
>>>I'm trying to output mutilple lines to a printer using Win32:rinter. I
>>>have only suceeded in printing one line so far. Does anyone know how

>
> force
>
>>>it to print multiple lines? The output is shows rectangles in between

>
> each
>
>>>word.
>>>
>>>Sample code below
>>>
>>>use strict;
>>>use Win32:rinter;
>>>my @array = keys %ENV;
>>>
>>>printMultiple();
>>>
>>>sub printMultiple {
>>> my $dc = new Win32:rinter( papersize => A4,
>>> description => 'Test,
>>> unit => 'mm') or die "Failed

>
> to
>
>>>create printer object";
>>> if ($dc) {
>>> my $textToPrint = join("\r\n",@oldarray);
>>> my $font = $dc->Font('Times New Roman', 12);
>>> $dc->Font($font);
>>> $dc->Color(0, 0, 0);
>>> $dc->Write($textToPrint, 10, 10);
>>> $dc->Close;
>>> }
>>>}
>>>__END__
>>>
>>>Jack
>>>
>>>

>>
>>What does you print show when you change the "\r\n" in the join to ':'?
>>my $textToPrint = join(':',@oldarray);

>
>
> Is this a trick question? It prints the colon of course.
>
> Jack
>
>


No trick, a diagnostic question since you did not include an example of
the output. Then the rectangles that are printed are either from the
\r or the \n. Try with just the \n and see what happens. Did you get
the rectangles? Did you get the print you wanted? Try with the \r and
do the same test. Try with "\n\n".

--

Len

 
Reply With Quote
 
Jack D
Guest
Posts: n/a
 
      06-10-2006
"Jack D" <(E-Mail Removed)> wrote in message
news:zmShg.25618$S61.24326@edtnps90...
> I'm trying to output mutilple lines to a printer using Win32:rinter. I
> have only suceeded in printing one line so far. Does anyone know how force
> it to print multiple lines? The output is shows rectangles in between each
> word.
>
> Sample code below
>
> use strict;
> use Win32:rinter;
> my @array = keys %ENV;
>
> printMultiple();
>
> sub printMultiple {
> my $dc = new Win32:rinter( papersize => A4,
> description => 'Test,
> unit => 'mm') or die "Failed to
> create printer object";
> if ($dc) {
> my $textToPrint = join("\r\n",@oldarray);
> my $font = $dc->Font('Times New Roman', 12);
> $dc->Font($font);
> $dc->Color(0, 0, 0);
> $dc->Write($textToPrint, 10, 10);
> $dc->Close;
> }
> }
> __END__
>

Just a follow up for any future Googlers.

After a direct e-mail to the Edgars Binans, the solution is to either write
in "draw mode", use Write2 or print the array element by element
incrementing the y value as you go. Working code below:

use Win32:rinter;

my @array = keys %ENV;

printAlpha();

sub printAlpha {
my $dc = new Win32:rinter(
papersize => A4,
description => 'Test Print',
unit => 'pt')
or die "Failed to create object";

if ($dc) {

my $font = $dc->Font('Times New Roman', 10);
$dc->Font($font);
$dc->Color(0, 0, 0);
my $v = 10;
foreach my $line (@array) {
$dc->Write($line, 10, $v);
$v+=10;
}
$dc->Close;
}
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
given char* utf8, how to read unicode line by line, and output utf8 gry C++ 2 03-13-2012 04:32 AM
Capturing the output of an external program line by line Aditya Mahajan Ruby 4 10-14-2007 11:28 PM
Force multi line field value to output with line breaks? bernadou ASP .Net Web Controls 2 01-23-2006 01:23 PM
line-by-line output from a subprocess Chermside, Michael Python 2 05-24-2005 01:02 AM
Capture external command output line by line on Windows 98 Dib Urim Perl Misc 4 11-23-2003 12:14 PM



Advertisments