How to download PDF automatically using js?

前端 未结 5 1284
不知归路
不知归路 2020-12-05 15:42

My scenario is that PDF file download automatically, then user fills it and when click on submit button in PDF it connect to java servlet and save it in DB.

         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 15:58

    1. for second point, get a full path to pdf file into some java variable. e.g. http://www.domain.com/files/filename.pdf

    e.g. you're using php and $filepath contains pdf file path.

    so you can write javascript like to to emulate download dialog box.

    Above code sends browser to pdf file by its url "http://www.domain.com/files/filename.pdf". So at last, browser will show download dialog box to where to save this file on your machine.

提交回复
热议问题