Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Win32::PowerPoint extension

by EnzoXenon (Novice)
on May 19, 2023 at 14:52 UTC ( #11152310=perlquestion: print w/replies, xml ) Need Help??

EnzoXenon has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to extend the Win32::PowerPoint module to alter the size of a page in PowerPoint.

In the Constants.pm module I've added the following to define the page names to the enumeration from the Microsoft documentation

ppSlideSize35MM => 4, ppSlideSizeA3Paper => 9, ppSlideSizeA4Paper => 3, ppSlideSizeB4ISOPaper => 10, ppSlideSizeB4JISPaper => 12, ppSlideSizeB5ISOPaper => 11, ppSlideSizeB5JISPaper => 13, ppSlideSizeBanner => 6, ppSlideSizeCustom => 7, ppSlideSizeHagakiCard => 14, ppSlideSizeLedgerPaper => 8, ppSlideSizeLetterPaper => 2, ppSlideSizeOnScreen => 1, ppSlideSizeOverhead => 5,

In the PowerPoint.pm module I've added a method to alter the page setup like this

sub page_setup { my ($self, $options) = @_; $options = {} unless ref $options eq 'HASH'; $self->presentation->PageSetup->SlideSize($options->{slidesize}); $self->presentation->PageSetup->SlideWidth($options->{width}); $self->presentation->PageSetup->SlideHeight($options->{height}); }

In my call to this function I try to set the slide size with no luck

# Set the slide size $PPT->page_setup( { slidesize => 'ppSlideSizeLetterPaper', width => 11*72, height => 8.5*72 } );

When I debug the code and print out the slide information ... from within PowerPoint.pm from this code

print "\nPowerPoint.pm(): slide size=" . $self->presentation->PageSetu +p->SlideSize . "\n"; print "PowerPoint.pm(): width=" . $self->presentation->PageSetup->Sl +ideWidth . "\n"; print "PowerPoint.pm(): height=" . $self->presentation->PageSetup->Sl +ideHeight . "\n\n";

I list out the options called (they seem to be right) and get the answers like this

PowerPoint.pm(): options: slidesize=ppSlideSizeLetterPaper height=612 width=792 PowerPoint.pm(): slide size=7 PowerPoint.pm(): width=960 PowerPoint.pm(): height=540
So, I can properly read the current values but I can't set new ones. Any wisdom would be greatly apprecaited.

Your humble apprentice formerly registered as nzsvz9 but can't find or fix his login so newly creating this EnzoXenon account

Replies are listed 'Best First'.
Re: Win32::PowerPoint extension
by Anonymous Monk on May 20, 2023 at 10:47 UTC
    Try a number here ppSlideSizeLetterPaper',
      Thanks - I did try this, before and after your suggestion just in case I was temporarily in an alternate universe, however it was unsuccessful. I've commented out all the versions I've tried.

      And the constants are defined in the sub-module so ppSlideSizeLetterPaper is a number as far a perl is concerned.

      # Set the slide size # $PPT->page_setup( { slidesize => 'ppSlideSizeLetterPaper', # width => 11*72, # height => 8.5*72 } ); # $PPT->page_setup( { slidesize => 'ppSlideSizeLetterPaper' } ); # $PPT->page_setup( { width => 11*72, # height => 8.5*72 } ); $PPT->page_setup( { slidesize => '5' } );
      Here's the result of trying a number:
      PowerPoint.pm(): options: slidesize=5 PowerPoint.pm(): slide size=7 PowerPoint.pm(): width=960 PowerPoint.pm(): height=540
      Ideas?
        For anyone watching ... this worked
        sub page_setup { my ($self, $options) = @_; $options = {} unless ref $options eq 'HASH'; # PPT.PageSetup.SlideSize = ppSlideSizeA4Paper # Const ppSlideSizeA4Paper = 3 # Microsoft constants # # Name Value Description # ppSlideSize35MM 4 35MM # ppSlideSizeA3Paper 9 A3 Paper # ppSlideSizeA4Paper 3 A4 Paper # ppSlideSizeB4ISOPaper 10 B4 ISO Paper # ppSlideSizeB4JISPaper 12 B4 JIS Paper # ppSlideSizeB5ISOPaper 11 B5 ISO Paper # ppSlideSizeB5JISPaper 13 B5 JIS Paper # ppSlideSizeBanner 6 Banner # ppSlideSizeCustom 7 Custom # ppSlideSizeHagakiCard 14 Hagaki Card # ppSlideSizeLedgerPaper 8 Ledger Paper # ppSlideSizeLetterPaper 2 Letter Paper # ppSlideSizeOnScreen 1 On Screen # ppSlideSizeOverhead 5 Overhead if ( defined $options->{SlideSize} ) { $self->presentation->PageSetup->{SlideSize} = $options->{SlideSize +}; print "PowerPoint.pm(): set SlideSize=2\n"; } if ( defined $options->{SlideWidth} ) { $self->presentation->PageSetup->{SlideWidth} = $options->{SlideWid +th}; print "PowerPoint.pm(): set SlideWidth=" . $options->{SlideWidth} + . "\n"; } if ( defined $options->{SlideHeight} ) { $self->presentation->PageSetup->{SlideHeight} = $options->{SlideHe +ight}; print "PowerPoint.pm(): set SlideHeight=" . $options->{SlideHeigh +t} . "\n"; } }

        Of course, I'll remove the print statements.

        Now ... if only I knew how to update a module for distribution ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11152310]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2023-06-07 23:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (29 votes). Check out past polls.

    Notices?