public function getAttribute($name, $inherited = true)
    {
        $dict = $this->getPageDictionary();

        if (isset($dict->value[$name])) {
            return $dict->value[$name];
        }

        $inheritedKeys = ['Resources', 'MediaBox', 'CropBox', 'Rotate'];
        if ($inherited && \in_array($name, $inheritedKeys, true)) {
            if ($this->inheritedAttributes === null) {
                $this->inheritedAttributes = [];
                $inheritedKeys = \array_filter($inheritedKeys, function ($key) use ($dict) {
                    return !isset($dict->value[$key]);
                });

                if (\count($inheritedKeys) > 0) {
                    $parentDict = PdfType::resolve(PdfDictionary::get($dict, 'Parent'), $this->parser);
                    while ($parentDict instanceof PdfDictionary) {
                        foreach ($inheritedKeys as $index => $key) {
                            if (isset($parentDict->value[$key])) {
                                $this->inheritedAttributes[$key] = $parentDict->value[$key];
                                unset($inheritedKeys[$index]);
                            }
                        }

                        /** @noinspection NotOptimalIfConditionsInspection */
                        if (isset($parentDict->value['Parent']) && \count($inheritedKeys) > 0) {
                            $parentDict = PdfType::resolve(PdfDictionary::get($parentDict, 'Parent'), $this->parser);
                        } else {
                            break;
                        }
                    }
                }
            }

            if (isset($this->inheritedAttributes[$name])) {
                return $this->inheritedAttributes[$name];
            }
        }

        return null;
    }
public function getAttribute($name, $inherited = true)
    {
        $dict = $this->getPageDictionary();

        if (isset($dict->value[$name])) {
            return $dict->value[$name];
        }

        $inheritedKeys = ['Resources', 'MediaBox', 'CropBox', 'Rotate'];
        if ($inherited && \in_array($name, $inheritedKeys, true)) {
            if ($this->inheritedAttributes === null) {
                $this->inheritedAttributes = [];
                $inheritedKeys = \array_filter($inheritedKeys, function ($key) use ($dict) {
                    return !isset($dict->value[$key]);
                });

                if (\count($inheritedKeys) > 0) {
                    $parentDict = PdfType::resolve(PdfDictionary::get($dict, 'Parent'), $this->parser);
                    while ($parentDict instanceof PdfDictionary) {
                        foreach ($inheritedKeys as $index => $key) {
                            if (isset($parentDict->value[$key])) {
                                $this->inheritedAttributes[$key] = $parentDict->value[$key];
                                unset($inheritedKeys[$index]);
                            }
                        }

                        /** @noinspection NotOptimalIfConditionsInspection */
                        if (isset($parentDict->value['Parent']) && \count($inheritedKeys) > 0) {
                            $parentDict = PdfType::resolve(PdfDictionary::get($parentDict, 'Parent'), $this->parser);
                        } else {
                            break;
                        }
                    }
                }
            }

            if (isset($this->inheritedAttributes[$name])) {
                return $this->inheritedAttributes[$name];
            }
        }

        return null;
    }
public function getAttribute ( $ name , $ inherited = true ) { $ dict = $ this -> getPageDictionary ( ) ; if ( isset ( $ dict -> value [ $ name ] ) ) { return $ dict -> value [ $ name ] ; } $ inheritedKeys = [ 'Resources' , 'MediaBox' , 'CropBox' , 'Rotate' ] ; if ( $ inherited && \ in_array ( $ name , $ inheritedKeys , true ) ) { if ( $ this -> inheritedAttributes === null ) { $ this -> inheritedAttributes = [ ] ; $ inheritedKeys = \ array_filter ( $ inheritedKeys , function ( $ key ) use ( $ dict ) { return ! isset ( $ dict -> value [ $ key ] ) ; } ) ; if ( \ count ( $ inheritedKeys ) > 0 ) { $ parentDict = PdfType :: resolve ( PdfDictionary :: get ( $ dict , 'Parent' ) , $ this -> parser ) ; while ( $ parentDict instanceof PdfDictionary ) { foreach ( $ inheritedKeys as $ index => $ key ) { if ( isset ( $ parentDict -> value [ $ key ] ) ) { $ this -> inheritedAttributes [ $ key ] = $ parentDict -> value [ $ key ] ; unset ( $ inheritedKeys [ $ index ] ) ; } } /** @noinspection NotOptimalIfConditionsInspection */ if ( isset ( $ parentDict -> value [ 'Parent' ] ) && \ count ( $ inheritedKeys ) > 0 ) { $ parentDict = PdfType :: resolve ( PdfDictionary :: get ( $ parentDict , 'Parent' ) , $ this -> parser ) ; } else { break ; } } } } if ( isset ( $ this -> inheritedAttributes [ $ name ] ) ) { return $ this -> inheritedAttributes [ $ name ] ; } } return null ; }
Get a page attribute.

@param string $name
@param bool $inherited
@return PdfType|null
@throws PdfParserException
@throws PdfTypeException
@throws CrossReferenceException
Get a page attribute .