Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide access to setCallbacks method #888

Closed
wants to merge 2 commits into from

Conversation

ta-tikoma
Copy link

Just open access to setCallbacks method. Use case:

        $pdf = Pdf::loadView(...)->setCallbacks([
            [
                'event' => 'end_frame',
                'f' => function ($info) {
                    $frame = $info['frame'];
                    /** @var CPDF $canvas */
                    $canvas = $info['canvas'];
                    /** @var DOMElement $node */
                    $node = $frame->get_node();
                    if ($node->nodeName === 'a') {
                        $href = $node->getAttribute('href');
                        if (strpos($href, 'file://') === 0) {
                            $url = substr($href, 7);
                            foreach ($canvas->get_cpdf()->objects as $key => $object) {
                                if ($object['type'] ?? '' === 'URI') {
                                    if (strpos($object['info'] ?? '', $url) !== false) {
                                        $canvas->get_cpdf()->objects[$key]['info'] = $url;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            ]
        ]);

@barryvdh
Copy link
Owner

Fixed with #892

@barryvdh barryvdh closed this Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants