“name” web pdf for better default save filename in Acrobat?

后端 未结 16 1748
难免孤独
难免孤独 2020-12-14 00:09

My app generates PDFs for user consumption. The \"Content-Disposition\" http header is set as mentioned here. This is set to \"inline; filename=foo.pdf\", which should be

16条回答
  •  猫巷女王i
    2020-12-14 01:11

    Apache's mod_rewrite can solve this.

    I have a web service with an endpoint at /foo/getDoc.service. Of course Acrobat will save files as getDoc.pdf. I added the following lines in apache.conf:

    LoadModule     RewriteModule         modules/mod_rewrite.so
    RewriteEngine  on
    RewriteRule    ^/foo/getDoc/(.*)$    /foo/getDoc.service     [P,NE]
    

    Now when I request /foo/getDoc/filename.pdf?bar&qux, it gets internally rewritten to /foo/getDoc.service?bar&qux, so I'm hitting the correct endpoint of the web service, but Acrobat thinks it will save my file as filename.pdf.

提交回复
热议问题