Hi Darek!

It's great. This API call is fantastic, is there, someweher more description
for this API call? It will be greate, if I can use this Stardoc... objects.
Regards
Gabor


----- Original Message -----
From: "Darek Adamkiewicz" <[EMAIL PROTECTED]>
To: "gabor.borus" <[EMAIL PROTECTED]>
Sent: Thursday, August 29, 2002 11:18 AM
Subject: Re: [perl-win32-gui-users] Fw: printing


>
> ----- Original Message -----
> From: "gabor.borus" <[EMAIL PROTECTED]>
> Date: Thu, 29 Aug 2002 09:11:58 +0200
> To: "Perl List" <perl-win32-gui-users@lists.sourceforge.net>
> Subject:  [perl-win32-gui-users] Fw: printing
>
>
> > > > > Hi!
> > > > >
> > > > > Thanks. Have you got any example script, that can print anything
to a
> > > > > printer?
> > > >
> > > > Yes. But on the other computer then I use now.
> > > > So I'll send it to you in one day or two. It's fairly simple.
Another
> > > solution:
> > > > search this mailing list - I posted here example code 3 or 4 months
ago.
> > > >
> > > > Regards
> > > > Darek
> > >
> >  Thanks Darek
> >  Please, send me. This is a simpler for me.
> >
>
> Below is modfied example code I found in NPRG manpage  (It came with
> package installed from ActiveState repository). It works (on Win98,
> ASPerl, very cheap 9-pin local printer).
>
> #!/usr/bin/perl -w
>
> use ExtUtils::testlib;
> use Win32::Wingraph;
> use Win32::NPRG qw(drawmatrix);
>
> $dc = new Win32::Wingraph(device=>"Panasonic KX-P1150",  desc=>'test') or
> die; #orientation=>'Landscape',
>
> $dc->SetPen(3);
> # "font, size, codepage" - the third argument is Windows font codepage
> # if you don't supply this it'll be set to russian !!!,
> # 0-westerneuropean, 238-polish, I don't know the hungarian ;(
> $dc->SetFont("Times New Roman Bold, 12, 0");
> $dc->TextOut(70, 180, "Blah blah blah");
> $dc->MoveTo(70, 200);
> $dc->LineTo(270, 200);
>
> print "Start\n";
>
> $rp=new NPRG(dc=>$dc);
> $rp->{'atbreak'} =
>  sub {
>          $rp->pushq({font=>'Times, 6, 0', opt=>'R', border=>'B',
> value=>'Very wisdom report about something '.$rp->pagenum(), width=>980}
>                             );
>                 $rp->pushq({height=>20, value=>' ', width=>100}
>                             );
>                 $rp->pushq({font=>'Arial italic, 16, 0', opt=>'-L',
> border=>'TBLR', value=>"Some header", width=>300, brush=>220},
>                             {font=>'Courier Bold, 12, 0', opt=>'-C',
> border=>'TBLR', value=>"Another header", width=>250, brush=>220},
>                             {value=>\&NPRG::drawmatrix, width=>400,
>                      matrix=>[
>                                   [ {font=>'Arial Bold Italic, 12',
> value=>'Month', border=>'TBLR', opt=>'C'}],
>                                   [
>                                       {font=>'Times New Roman,8',
> value=>'I', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,8',
> value=>'II', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,8',
> value=>'III', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,8',
> value=>'IV', border=>'TBLR', opt=>'-C'},
>                                   ],
>                                   [
>                                       {font=>'Times New Roman,7',
> value=>'I', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'II', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'III', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'IV', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'V', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'VI', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'VII', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'VIII', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'IX', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'X', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'XI', border=>'TBLR', opt=>'-C'},
>                                       {font=>'Times New Roman,7',
> value=>'XII', border=>'TBLR', opt=>'-C'},
>                                    ]
>                                 ],
>                              }
>                             );
>                   $rp->pushq({width=>950, height=>3, brush=>0});
>                   $rp->flushq();
>                   print "Here\n";
>                };
>
> $rp->flushq();
> print "End\n";
>
> #================================================================
> In addition
> The following code is a part of source code from the message:
> (it works for me)
>
> #!perl -w
> use strict;
> # Win32::API GDI printer test code
>
> use Win32::API;
>
> my $PrintDialog = new Win32::API('comdlg32', 'PrintDlg', ['P'],  'N');
> my $GlobalLock = new Win32::API('kernel32', 'GlobalLock', ['N'], 'N');
> my $GlobalFree = new Win32::API('kernel32', 'GlobalFree', ['N'],
> 'N');
> my $GetDeviceCaps = new Win32::API('gdi32', 'GetDeviceCaps',
> ['N','N'], 'N');
> my $GetTextMetrics = new Win32::API('gdi32', 'GetTextMetrics',
> ['N','P'], 'N');
> my $StartDoc = new Win32::API('gdi32', 'StartDoc', ['N', 'P'] , 'N');
> my $StartPage = new Win32::API('gdi32', 'StartPage', ['N'], 'N');
> my $TextOut = new Win32::API('gdi32', 'TextOut',
> ['N','I','I','P','I'], 'N');
> my $EndPage = new Win32::API('gdi32', 'EndPage', ['N'], 'N');
> my $EndDoc = new Win32::API('gdi32', 'EndDoc', ['N'], 'N');
> my $GetLastError =   new Win32::API('kernel32', 'GetLastError',   [],
> 'N');
> my $FormatMessage =  new Win32::API('kernel32', 'FormatMessage',
> ['N','P','N','N','P','N','P'],'N');
>
> sub ShowError {
>    my $function = shift;
>    my $message = " " x 1024;
>    $FormatMessage->Call(0x1000, 0, $GetLastError->Call(), 0,
> $message, 1024, 0);
>    $message =~ s/\s+$//;
>    print "$function: $message\n";
>    exit;
> }
>
> # user dialog to select printer
> # page setup dialog selected since pages, selection and copies are
> not used here
> # paper size and orientation shown instead
> my $pd = pack("Lx16Lx42", 66, 0x140); # pd_size, flags =
> RETURNDC | PRINTSETUP
> $PrintDialog->Call($pd) or die "Cancelled\n";
> # get device mode and device context
> my ($devmode, $dc) = unpack("x8Lx4L", $pd);
>
> # this part is just to print a notice line
> # and to practice mucking with pointers in structures
> # otherwise, examining devmode is not needed for GDI
> # devmode is a handle to movable global memory
> my $handle = $devmode;
> # get actual memory pointer
> unless ($devmode = $GlobalLock->Call($handle))
> {ShowError('GlobalLock')};
> # get perl to use long integer as a pointer
> # and retrieve the printer relevant part of the devmode structure
> $devmode = unpack('P104', pack('L', $devmode));
> # release the global memory
> unless ($GlobalFree->Call($handle) == 0) {ShowError('GlobalFree')};
> # these strings are blank padded
> my ($devicename, $orient, $duplex, $formname) =
> unpack('A32x12Sx16Sx6A32', $devmode);
> $orient = ('Portrait', 'Landscape')[--$orient];
> $duplex = ('', 'Duplex')[$duplex > 1];
> print "Printing to $devicename on $formname paper, $orient
> $duplex\n";
>
> ------------------------
> 2)To print DC object containing text and lines I use
> Win32::NPRG (and its base Win32::Wingraph) modules - which
> can generate EMF format file (sent directly to the printer or
> saved) - but there isn't possible to embed image object in the file
> (using this module)
>
> Regards
> Darek
> --
> __________________________________________________________
> Sign-up for your own FREE Personalized E-mail at Mail.com
> http://www.mail.com/?sr=signup
>
>
>
>


Reply via email to