Skip to content

Shapes return zeroes x,y,w,h #877

Description

@disasterovich

ppt-example1.pptx

Hi, I'm trying to import a file

    $pptReader          = IOFactory::createReader($reader);
    $oPHPPresentation   = $pptReader->load($path);

    $designData = [];

    $i=0;
    foreach ($oPHPPresentation->getAllSlides() as $oSlide) {
        foreach ($oSlide->getShapeCollection() as $oShape) {
            if ($oShape instanceof Group)
                foreach ($oShape->getShapeCollection() as $oShapeChild) {
                    $designData['pages'][$i]['decors'][] =                         [
                        'x'     => $oShapeChild->getOffsetX(),
                        'y'     => $oShapeChild->getOffsetY(),
                        'w'     => $oShapeChild->getWidth(),
                        'h'     => $oShapeChild->getHeight(),
                        'angle' => $oShapeChild->getRotation(),
                    ];
                }
                    
            else
                $designData['pages'][$i]['decors'][] =                         [
                    'x'     => $oShape->getOffsetX(),
                    'y'     => $oShape->getOffsetY(),
                    'w'     => $oShape->getWidth(),
                    'h'     => $oShape->getHeight(),
                    'angle' => $oShape->getRotation(),
                ];
        }
        $i++;
    }

But I getting almost all zero values:

array:1 [
"pages" => array:5 [
0 => array:1 [
"decors" => array:2 [
0 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
1 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
]
]
1 => array:1 [
"decors" => array:2 [
0 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
1 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
]
]
2 => array:1 [
"decors" => array:2 [
0 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
1 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
]
]
3 => array:1 [
"decors" => array:5 [
0 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
1 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
2 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
3 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
4 => array:5 [
"x" => 0
"y" => 0
"w" => 0
"h" => 0
"angle" => 0
]
]
]
4 => array:1 [
"decors" => array:1 [
0 => array:5 [
"x" => 399
"y" => 414
"w" => 153
"h" => 55
"angle" => 0
]
]
]
]
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions