Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By drupalfriend123 on
Hi,
I have a pdf file. I like to have an opt-in block which will allow people to enter email address and then click download. PDF file should be downloaded to their machine. Please advise.
Comments
Use the Webform module https:
Use the Webform module https://www.drupal.org/project/webform to collect the email address. You can configure the form to be exposed as a block.
In the Webform module configuration, you can indicate a page to redirect the user upon form submission. In this page, include the download link.
Thank you. I got everything
Thank you. I got everything except the download part "In this page, include the download link.". How can I have a link that will download the file?
It is not clear to me the
It is not clear to me the step(s) that you are having a problem with.
In summary, I would:
Create a new page node.
In the Body of the page, include the hyperlink to the PDF, e.g.
<a href="http://www.example.com/sites/default/files/mypdf.pdf">Download my PDF!</a>
In the
<a></a>
tag, you can include thetarget="_blank"
attribute to force the PDF to open (or download) from a new tab. (How the PDF will open is browser dependent and/or subject to the user's browser preference settings.)If you want to force the PDF to download, i.e. open a 'save as' dialog box, try putting the following line in the .htaccess file of the docroot:
Thank you. That is what I
Thank you. That is what I needed.
Will the new page be
Will the new page be unavailable for a direct link?