Magento 2.x – create a PDF and its downloadable link


With the following code snippet, you will be able to create a link in your store, where an action is called and a custom PDF is sent to download.

Bear in mind, that first, you will need to create your action, in app\code\<vendor>\<module>\Controller\<controller>\<action>.php, extending the core \Magento\Framework\App\Action\Action .

Then, you can use the following skeleton as kickoff point for your pdfs.

 

The following file should be brought for download.

 

 

source: https://webkul.com/blog/generate-pdf-programmatically-magento2/