Auto-download PDF using Product URL Metafield

Auto-download PDF using Product URL Metafield

GREENS
Tourist
18 0 2

Hello, 

 

I am trying to get my customers to auto download a PDF when they click on a link on my product page. Each product will have a different link, so I set up a metafield URL for the PDF and embedded the url to the product page (see image). Right now, the link just opens to a new tab. Is there a way to HTML code it so it auto downloads the PDF when you click on it?

 

Website: greenlyliving.co

password: pdf

 

Thanks in advance.

 

Screen Shot 2023-02-27 at 11.26.56 AM.png

Replies 2 (2)

EcomGraduates
Shopify Partner
858 71 124

hello there  

 

Yes, there is a way to code the link so that it auto downloads the PDF when clicked. You can add the "download" attribute to the link, like this:

<a href="your-pdf-url.pdf" download>Link text</a>

Just replace "your-pdf-url.pdf" with the URL of your PDF file and "Link text" with the text you want to use for the link.

This should force the browser to download the PDF instead of opening it in a new tab. However, please note that this behavior may vary depending on the browser and device being used by your customers.

 


 If this fixed your issue, likes and accepting as a solution are highly appreciated
|  Build an online presence with our custom-built Shopify Theme: EcomifyTheme
|  Check out our reviews: Trustpilot Reviews
|  We are Shopify Partners: EcomGraduates Shopify Partner



GREENS
Tourist
18 0 2

Hello, 

 

Yes I tried adding the download attribute, but it does not auto download, it just opens into a new tab. See pic. Is it possible that it's a metafield that's causing it to open to a new tab? Trying to see if there's a work-around for this. 

Also I uploaded the PDF onto Shopify files. 

 

Screen Shot 2023-02-28 at 8.11.22 AM.png