B4J Question B4J Webapp :How to Prevent Reader From Opening PDFs in explorers

Discussion in 'B4J Questions' started by markcasio, Jul 8, 2019.

  1. markcasio

    markcasio Member Licensed User


    Is there a way to configure jserver to download my pdf file instead of showing a preview ?
    I used content-disposition without result.
    <meta name="content-disposition" content="inline;filename=testfile.pdf">
  2. Erel

    Erel Administrator Staff Member Licensed User

    Moved to B4J forum.
  3. markcasio

    markcasio Member Licensed User

    added hanlde using resp.SetHeader("Content-disposition", $"attachment; filename=${myfileName}"$)
    Still no result , but I'm getting close.
  4. alwaysbusy

    alwaysbusy Expert Licensed User

    Have you tried also setting the content type as octet-stream? (in addition to your SetHeader)

    resp.ContentType = "application/octet-stream"
    hibrid0 and markcasio like this.
  5. markcasio

    markcasio Member Licensed User

    Problem solved.
    Thank you Alwaysbusy, after adding the contenttype the file can be saved using the dialog.
    alwaysbusy likes this.
  6. moster67

    moster67 Expert Licensed User

  7. markcasio

    markcasio Member Licensed User

    I understand monster67 , inline is opening the file and attachment is downloading it. But without setting the contenttype my file won't download.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice