I need help ? ctp to html string

I have generate invoice in ctp. and i want that generate html to my function to create pdf. My Question How to convert .ctp file to html string. Please any suggestion.

$this->viewBuilder()
     ->setTemplatePath('Example');
            
$renderedHtml = (string)$this->render('hello', 'layout');

will give you renderd html of Example/hello.ctp with layout layout

1 Like

Thanks, that was really helpful.

You could/should just use CakePDF which will do it for you

1 Like

Yes Sir, This works perfectly. :blush:

1 Like