CakePdf - set metadata

If possible set metadata in pdfdocument via plugin?

I would like to add a name, creator, application meta data.

I’ve never used this plugin, so this is speculation:

It seems like the actual rendering engine is the code that would have to support your metadata additions. And you would have to intervene somehow in the rendering process to add your request to the engine along with the normal plugin rendering requests.

Just spitballing but looking at this code in the documentation:

 public function view($id = null)
            $invoice = $this->Invoice->get($id);
                'pdfConfig' => [
                    'orientation' => 'portrait',
                    'filename' => 'Invoice_' . $id
            $this->set('invoice', $invoice);

It looks like the plugin will be taking over the Controller::render() process. You would have to collaborate in that process to get your setMetadata requests passed up to the engine.

Most likely, this specific feature is not in the plugin because this tool must work with many different engines and so it will only be written to use the features common to all engines.

1 Like