0

when I try to load my file it loads only file URL what is the solution I try this but it loads only file path in pdf file

return PDF::loadFile(public_path().'/your_html.html')->stream('download.pdf');

1 Answer 1

0

Your file is in HTML format and also your path indicates it's outside the resources folder, you have to add your HTML file in blade format in resources folder.

loadView function first render the view and then pass it to loadHTML function.

DomPDF https://github.com/barryvdh/laravel-dompdf/blob/00443b33aff68f9e996de536c8f62735c4042131/src/PDF.php

    public function loadView(string $view, array $data = [], array $mergeData = [], ?string $encoding = null): self
    {
        $html = $this->view->make($view, $data, $mergeData)->render();
        return $this->loadHTML($html, $encoding);
    }

And if you want to load html file not in blade format from resource folder so you can checkout how to include html extension file.

Laravel Blade @include .html files

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.