arpad.szasz has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

While printing from a wxPerl application, I'm trying to set orientation to landscape using the following code:

my $printer = Wx::Printer->new; my $print_data = Wx::PrintData->new; $print_data->SetOrientation(wxLANDSCAPE); $printer->GetPrintDialogData->SetPrintData($print_data);

Unfortunately this does not work. I appreciate any answers on how to do it properly.

Thanks!

Replies are listed 'Best First'.
Re: Landscape printing in wxPerl
by jmlynesjr (Deacon) on Jun 27, 2013 at 23:32 UTC

    Try something like...

    my $printer = Wx::Printer->new; my $print_data = Wx::PrintData->new; my $page_setup_dialog_data = Wx::PageSetupDialogData->new; $print_data->SetOrientation(wxLANDSCAPE); $page_setup_dialog_data->SetPrintData;

    Untested. From reading http://docs.wxwidgets.org/trunk/overview_printing.html

    James

    There's never enough time to do it right, but always enough time to do it over...

Re: Landscape printing in wxPerl
by Anonymous Monk on Jun 27, 2013 at 07:22 UTC

    Unfortunately this does not work.

    What happens? Are you using strict/warnings, what do you get for value of wxLANDSCAPE?

      It still prints in portrait mode.

        #!/usr/bin/perl -l -- use Wx qw/ :allclasses /; print Wx::wxPORTRAIT(); print Wx::wxLANDSCAPE(); my $pd = Wx::PrintData->new; print $pd->GetOrientation; $pd->SetOrientation( Wx::wxPORTRAIT() ); print $pd->GetOrientation; $pd->SetOrientation( Wx::wxLANDSCAPE() ); print $pd->GetOrientation; $pd->SetOrientation( 666 ); print $pd->GetOrientation; __END__ 1 2 1 1 2 666

        SetOrientation doesn't do much validation, if you feed it junk, I imagine the users/consumers of wxPrintData assumes the default (wxPORTRAIT)

        and Are you using strict/warnings, what do you get for value of wxLANDSCAPE?