Showing results for 
Search instead for 
Did you mean: 

Magento 2 link in a module


Magento 2 link in a module

Hello it's me again


I'm a french student and I'm actually trying to learn how to use Magento 2. I'm actually trying  to put 2 pdf in my module that i can open in a certain page but i can't do it, i can only display them by putting them in the media folder but it's not very good for what i have to do can someone explain me how i can use them since my module folder please.

Tags (2)

Re: Magento 2 link in a module

You can add your pdf in your custom module.


Add pdf file in your module,


now run command for deployment,


php bin/magento setup:static-content:deploy

Now you can use your pdf file in any template file like this,


$pdf1 = $block->getViewFileUrl('Vendor_Modulename::pdf/custom1.pdf');
<a href="<?php echo $pdf1;?>">pdf1</a>

$pd2 = $block->getViewFileUrl('Vendor_Modulename::pdf/custom2.pdf');
<a href="<?php echo $pdf2;?>">pdf1</a>

Please let me know if you have query.


If solutions helpful, click Kudos and Accept as solutions 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Magento 2 link in a module

Thanks for your answer


after a try i have an error 404 here is the url link given by the href of the pdf



Re: Magento 2 link in a module



Add pdf file in your module,



Then do static content deploy.


If works then mark as solution. 

Re: Magento 2 link in a module

It work thanks you very much Sunil and Rakesh