Download file (unknown link)

I have a button on my web page that download a file (PDF or jpg) but i don’t know the url because it’s generated automatically each time.
The button normally open a new tab in the browser but in the webviewer it not appear and the file downloaded is an HTML of the page or a corrupted file.
I tried also a visualizer and it shows the HTML of the new tab and not the file I want to see or download.
How can I overcome this two steps and get the direct link?

Hi! @Stefano_Biscotti
Can you please show the blocks!

and also welcome to the community!