1

I want to change the default text size of a AutoShape in PhpOffice/PhpPresentation

Following the example of :[https://github.com/PHPOffice/PHPPresentation/blob/develop/samples/Sample_21_AutoShape.php]

I defined my code:

<?php
...
$currentSlide2 = createTemplatedSlide($objPHPPresentation, false);

 $autoShape = new AutoShape();
        
        $autoShape->setType(AutoShape::TYPE_ROUNDED_RECTANGLE)
        ->setText('HELLO WORLD')
        ->setOffsetX(15)
        ->setOffsetY(15)
        ->setWidthAndHeight(230, 40);

        $autoShape->getOutline()
        ->setWidth(0)
        ->getFill()
        ->setFillType(Fill::FILL_SOLID)
        ->setStartColor(new Color(Color::COLOR_BLUE));

$currentSlide2->addShape($autoShape);
?>

Works correctly, generating: Image AutoShape

But as much as I've searched, I couldn't modify the size of the text, printing the object that the AutoShape function returns I can see:

PhpOffice\PhpPresentation\Shape\AutoShape Object
(
    [text:protected] => HELLO WORLD
    [type:protected] => roundRect
    [outline:protected] => PhpOffice\PhpPresentation\Style\Outline Object
        (
            [fill:protected] => PhpOffice\PhpPresentation\Style\Fill Object
                (
                    [fillType:PhpOffice\PhpPresentation\Style\Fill:private] => solid
                    [rotation:PhpOffice\PhpPresentation\Style\Fill:private] => 0
                    [startColor:PhpOffice\PhpPresentation\Style\Fill:private] => PhpOffice\PhpPresentation\Style\Color Object
                        (
                            [argb:PhpOffice\PhpPresentation\Style\Color:private] => FF0000FF
                            [hashIndex:PhpOffice\PhpPresentation\Style\Color:private] => 
                        )

                    [endColor:PhpOffice\PhpPresentation\Style\Fill:private] => PhpOffice\PhpPresentation\Style\Color Object
                        (
                            [argb:PhpOffice\PhpPresentation\Style\Color:private] => FFFFFFFF
                            [hashIndex:PhpOffice\PhpPresentation\Style\Color:private] => 
                        )

                    [hashIndex:PhpOffice\PhpPresentation\Style\Fill:private] => 
                )

            [width:protected] => 0
        )

    [container:protected] => PhpOffice\PhpPresentation\Slide Object
        (
            [isVisible:protected] => 1
            [slideLayout:PhpOffice\PhpPresentation\Slide:private] => PhpOffice\PhpPresentation\Slide\SlideLayout Object
                (
                    [slideMaster:protected] => PhpOffice\PhpPresentation\Slide\SlideMaster Object
                        (
                            [slideLayouts:protected] => Array
                                (
                                    [0] => PhpOffice\PhpPresentation\Slide\SlideLayout Object
 *RECURSION*
                                )

                            [colorMap] => PhpOffice\PhpPresentation\Style\ColorMap Object
                                (
                                    [mapping:protected] => Array
                                        (
                                            [bg1] => lt1
                                            [tx1] => dk1
                                            [bg2] => lt2
                                            [tx2] => dk2
                                            [accent1] => accent1
                                            [accent2] => accent2
                                            [accent3] => accent3
                                            [accent4] => accent4
                                            [accent5] => accent5
                                            [accent6] => accent6
                                            [hlink] => hlink
                                            [folHlink] => folHlink
                                        )

                                )

                            [textStyles:protected] => PhpOffice\PhpPresentation\Style\TextStyle Object
                                (
                                    [bodyStyle:protected] => Array
                                        (
                                            [1] => PhpOffice\PhpPresentation\Shape\RichText\Paragraph Object
                                                (
                                                    [richTextElements:PhpOffice\PhpPresentation\Shape\RichText\Paragraph:private] => Array
                                                        (
                                                        )

                                                    [alignment:PhpOffice\PhpPresentation\Shape\RichText\Paragraph:private] => PhpOffice\PhpPresentation\Style\Alignment Object
                                                        (
                                                            [supportedStyles:PhpOffice\PhpPresentation\Style\Alignment:private] => Array
                                                                (
                                                                    [0] => l
                                                                    [1] => l
                                                                    [2] => r
                                                                )

                                                            [horizontal:PhpOffice\PhpPresentation\Style\Alignment:private] => ctr
                                                            [vertical:PhpOffice\PhpPresentation\Style\Alignment:private] => base
                                                            [textDirection:PhpOffice\PhpPresentation\Style\Alignment:private] => horz
                                                            [level:PhpOffice\PhpPresentation\Style\Alignment:private] => 0
                                                            [indent:PhpOffice\PhpPresentation\Style\Alignment:private] => -34.110236220472
                                                            [marginLeft:PhpOffice\PhpPresentation\Style\Alignment:private] => 0
                                                            [marginRight:PhpOffice\PhpPresentation\Style\Alignment:private] => 0
                                                            [marginTop:PhpOffice\PhpPresentation\Style\Alignment:private] => 0
                                                            [marginBottom:PhpOffice\PhpPresentation\Style\Alignment:private] => 0
                                                            [isRTL:PhpOffice\PhpPresentation\Style\Alignment:private] => 
                                                            [hashIndex:PhpOffice\PhpPresentation\Style\Alignment:private] => 
                                                        )

                                                    [font:PhpOffice\PhpPresentation\Shape\RichText\Paragraph:private] => PhpOffice\PhpPresentation\Style\Font Object
                                                       (                                                         [name:PhpOffice\PhpPresentation\Style\Font:private] => Calibri
                                                                                                                  size:PhpOffice\PhpPresentation\Style\Font:private] => 32...

size:PhpOffice\PhpPresentation\Style\Font:private] => 32

Apparently that line defines the font size but I don't know how to modify it, if someone could tell me how to achieve it I would appreciate it

0 Answers0