Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 868413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:08:09+00:00 2026-05-15T10:08:09+00:00

I have a php add which calls LaTeX then passes the PDF to the

  • 0

I have a php add which calls LaTeX then passes the PDF to the browser. Since my users will be paying for this service, I want to make sure they are given the option to save the PDF rather than hitting my server again and again.

exec("cd tex && latex {$_SESSION['sen_id']}.tex && pdflatex {$_SESSION['sen_id']}.tex", $output);
$pdf = substr($file,0,-3).'pdf';
if (file_exists($pdf)) {
  //header('Content-Description: File Transfer');
  header('Content-Type: application/pdf');
  //header('Content-Length: ' . filesize($pdf));
  header('Content-Disposition: attachment;filename='.date('Ymd-His').'-'.basename($pdf));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: no-cache');
  header('Pragma: no-cache');
  ob_clean();
  flush();
  readfile($pdf);
  exit;
} else {
  echo '<h1>No PDF Produced</h1>';
  echo nl2br(print_r($output,true));
}

Using Wireshark, I have noticed that the Content-Disposition header is either not set or doesn’t reach the client.

HTTP/1.1 200 OK\r\n
Date: Tue, 22 Jun 2010 14:15:10 GMT\r\n
Server: Apache/2.0.55 (Ubuntu) mod_jk/1.2.14 mod_python/3.1.4 Python/2.4.3 PHP/5.1.2 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2 Perl/v5.8.7\r\n
X-Powered-By: PHP/5.1.2\r\n
Set-Cookie: SESS0d6c65b0599f5b70f6bbc50cfc5b2f94=2b23ba1f74f5f1f641365e9fbb45870d; expires=Thu, 15 Jul 2010 17:48:30 GMT; path=/; domain=.<domain removed>\r\n
Content-Transfer-Encoding: binary\r\n
Expires: 0\r\n
Cache-Control: no-cache\r\n
Pragma: no-cache\r\n
Connection: close\r\n
Transfer-Encoding: chunked\r\n
Content-Type: application/pdf\r\n
\r\n

So far, the tips I’ve found say “use octet-steam”, “don’t use octet-stream”, “put spaces after the colons”, “Capitalise each word” and “wrap the filename in quotes”. I guess there’s a lot of misinformation put out by people who got lucky.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:08:10+00:00Added an answer on May 15, 2026 at 10:08 am

    I don’t know why the header’s being stripped, but this page describes how you can encode the file name in the content disposition header and its implications for browser interoperability.

    In these cases, I settled for the solution I wrote in the PHP manual page here (see the first example).

    In your case, you’re using an invalid header, which, however, should work with all the major browsers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP file which will return something like <div id=title>Add Us On
I have a PHP script which calls another script in order to add IP
What code do you need to add in PHP to automatically have the browser
I have a page called example1.php . This page calls another page with some
I have a PHP page, in Wordpress. When I add a inline Thickbox to
I have a PHP application using an Oracle XE database. Whenever I add a
I have a set of .php files in a folder, I want to add
Context: I have to add an online payment system, on a quite old PHP
I have the following code in a php page <div class=vmenu> <div class=first_li><span >Add
I have php file with form which the user need to enter three parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.