Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How to generate pdf files on server side #27

Copy link
Copy link

Description

@BigAndini
Issue body actions

Hi,

maybe somebody besides me is searching for a solution on how to generate pdf files on server side. Here is a small example that works for me. Maybe it finds its way to the readme. :)

$pdfView = new ViewModel();
# When the action can be found at:
# MyModule/MyController/mypdf
# the path to the according template would be:
# my-module/my-controller/mypdf
$pdfView->setTemplate('my-module/my-controller/mypdf');
$pdfView->setVariables(array(
    'somevar' => $somevar,
));
$pdfRenderer = $this->getServiceLocator()->get('ViewPdfRenderer');
$html = $pdfRenderer->getHtmlRenderer()->render($pdfView);
$pdfEngine = $pdfRenderer->getEngine();

$pdfEngine->load_html($html);
$pdfEngine->render();
$pdfContent = $pdfEngine->output();

# make sure to create public/pdf before
file_put_contents(getcwd().'/public/pdf/mypdf.pdf', $pdfContent);

greetings
Andi

P.S.: This is more an enhancement for the readme than a real issue, but I don't know how to change the issue type on github, yet.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.