Is the example below meant to go into a link (<a href=***></a>)? Or is it meant for the address field on the browser? If I type "http://localhost/test.php/whatever.pdf" in the address field I get a server error which I was also expecting to be hornest. I don't see how that should work.
"Mike Flynn" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Use a slash and then the filename.pdf. So > http://whatever/stuff.php?options/desired_filename.pdf would do it. It's > ok that you aren't linking to a real file, it doesn't matter. Just the > file that you want the .pdf document to be known as to the user's browser. > > At 05:07 PM 2/26/2002 +0100, Sviss Cobazor wrote: > >Hmm in my case there is no file to link to. The pdf document doesn't exist, > >it's generated on-the-fly. Take this example: > > > >test.php contains: > > > ><? > >function topdf($file, $options = "") { > > header("Content-Type: application/pdf"); > > flush(); > > passthru("C:\htmldoc -t pdf14 --quiet --jpeg size A4 --webpage $options > >\"$file\""); > >} > > > >$url = "http://localhost/whatever.html"; > > > >topdf($url); > >?> > > > >So the idea was to write the address "http://localhost/test.php" and the > >browser would load Acrobat Reader and show the pdf document generated from > >"whatever.html". > > > >So how do I get the ".pdf" added? > >By typing the address "http://localhost/test.php?.pdf" ? Doesn't seem to > >work. > > > >"Mike Flynn" <[EMAIL PROTECTED]> wrote in message > >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Yes, this has been documented extensively on the web. The fix is to put a > > > pdf extension at the end of the url call to your script that is returning > > > the pdf file. You can use an arbitrary filename ending in .pdf, or you > >can > > > use the actual filename of the .pdf file, which would be preferable so > >that > > > if the user tries to save the .pdf file, the default filename is > > > correct. So what this means is that the script that is linking to your > > > .pdf-returning script needs to know the filename/that it is a .pdf file, > > > ahead of time. So you want to do something like this: > > > > > > <?php > > > $query = 'SELECT strFileFilename FROM tblFiles '; > > > $query .= "WHERE intFileID=$id"; > > > $filename = mysql_result(mysql_query($query), 0); > > > print "<a href=\"/stuff/getfile.php?id=$id/$filename\">Here's the > >PDF</a>\n"; > > > ?> > > > > > > -Mike > > > > > > At 03:09 PM 2/26/2002 +0100, Sviss Cobazor wrote: > > > >However, sigh, IE seems to have a bug so that Acrobat Reader is only > >loaded > > > >when the URL ends with ".pdf" aka IE doesn't give a rats about the header > > > >sent to it. > > > >Using Telnet I can see that the pdf page is returned correctly but when > > > >using IE I still get a blank page due to the fact that no (pre-generated) > > > >pdf document is sent to it and therefore the URL doesn't contain a > > > >"whatever.pdf" ind the end and therefore doesn't load Acrobat Reader. > > > >Look at this example: > > > > > > > >header("Content-Type: application/pdf"); > > > >flush(); > > > >passthru("C:\htmldoc -t pdf14 --quiet --jpeg size A4 --webpage > > > >\"http://localhost/whatever.html\""); > > > > > > > >This works fine with Telnet (where output is nonsense), > > > >but doesn't with IE (where the output would make sense). > > > > > > > >Does anyone have a solution to this? > > > >How to get IE to understand that the data sent to it is to be handled as > >a > > > >pdf document (as in load Acrobat Reader)? > > > > > > > > > > > > > > > >"Sviss Cobazor" <[EMAIL PROTECTED]> wrote in message > > > >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > It seemed that it was Putty itself that wouldn't work for me (don't > >ask me > > > > > why). > > > > > So I used Telnet and it worked. > > > > > After having my advicor (this is a education project) visiting me we > >found > > > > > out why that passthru() function didn't work. > > > > > It's very simple really, passthru() doesn't allow spaces in paths so > > > > > "C:\program files\etc." becomes "C:\program" => false path. > > > > > Removing the application (htmldoc.exe) to "C:\" instead did the job. > > > > > > > > > > For anyone else having same problems this is the correct way to type > >it > > > >(my > > > > > example): > > > > > > > > > > <? > > > > > function topdf($filename, $options = "") { > > > > > header("Content-Type: application/pdf"); > > > > > flush(); > > > > > passthru("C:\htmldoc -t pdf14 --quiet --jpeg size A4 --webpage > > > >$options > > > > > \"$filename\""); > > > > > } > > > > > ?> > > > > > > > > > > This function now works and sends the result pdf directly to the > >browser. > > > > > > > > > > Thanks for your time Court, I wouldn't have thought of using Telnet > >myself > > > > > :) > > > > > > > > > > ~ Sviss > > > > > > > > > > "Court Shrock" <[EMAIL PROTECTED]> wrote in message > > > > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > > To explain the 400 bad request, you most likely had a typo when you > > > >typed > > > > > in > > > > > > the HTTP request. The request is case-sensitive and very > >particular. > > > > > Most > > > > > > likely, the "Host: localhost" portion of the request messed up > >somehow. > > > > > > > > > > > > When you get a "HTTP/1.1 200 OK" response, that means that the > >webserver > > > > > > accepted the request and will process your request. In order to > >test > > > > > > whether or not the passthru function is doing things properly, you > >are > > > > > > verifying what is being sent to the browser by simulating what the > > > >browser > > > > > > would send to your webserver and then what the browser is getting in > > > > > > response. It will all start to make sense when you start seeing > >your > > > > > files > > > > > > output--of course, in the request that I had you type, I assumed the > > > >file > > > > > > that returns the pdf is named "index.php" or whatever file your > > > >webserver > > > > > > will retrieve when it gets a root "/" request. If this is not the > >case, > > > > > you > > > > > > need to replace the "GET / HTTP/1.1" line with "GET /yourfile.php > > > > > HTTP/1.1" > > > > > > or even "GET /yourfile.php?var1=whatever__yougettheidea HTTP/1.1". > > > > > > > > > > > > passthru is working properly if you see something like: > > > > > > HTTP/1.1 200 OK > > > > > > Date: Mon, 25 Feb 2002 23:20:35 GMT > > > > > > Server: Apache/1.3.20 (Unix) PHP/4.0.6 mod_ssl/2.8.4 OpenSSL/0.9.6 > > > > > > X-Powered-By: PHP/4.0.6 > > > > > > Transfer-Encoding: chunked > > > > > > Content-Type: application/pdf > > > > > > > > > > > > [lots of binary data] > > > > > > > > > > > > it isn't working if you see something like this: > > > > > > HTTP/1.1 200 OK > > > > > > Date: Mon, 25 Feb 2002 23:20:35 GMT > > > > > > Server: Apache/1.3.20 (Unix) PHP/4.0.6 mod_ssl/2.8.4 OpenSSL/0.9.6 > > > > > > X-Powered-By: PHP/4.0.6 > > > > > > Transfer-Encoding: chunked > > > > > > Content-Type: text/html > > > > > > > > > > > > <html>some stupid html, or nothing at all</html> > > > > > > > > > > > > in which case, I would try a different method to verify that data is > > > > > > properly passing between php and htmldoc.exe. > > > > > > > > > > > > I hope this has addressed some of the confusion. > > > > > > Court > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: Sviss Cobazor [mailto:[EMAIL PROTECTED]] > > > > > > > Sent: Monday, February 25, 2002 5:12 PM > > > > > > > To: [EMAIL PROTECTED] > > > > > > > Subject: Re: [PHP-WIN] passthru() on Win98 ?? > > > > > > > > > > > > > > > > > > > > > I followed your instructions and got: > > > > > > > > > > > > > > HTTP/1.1 400 bad request > > > > > > > > Date: Tue, 26 Feb 2002 01:05:57 GMT > > > > > > > > Server: Apache/1.3.20 (Win32) > > > > > > > > Connection: close > > > > > > > > Content-Type: text/html charset=iso-8859-1 > > > > > > > > > > > > > > ... And then the same in html source ... (in the putty window) > > > > > > > > > > > > > > So I didn't get what was expected but either way I'm not sure > > > > > > > what to do if > > > > > > > I did. > > > > > > > > > > > > > > > > > > > > > > > > > >-- > > > >PHP Windows Mailing List (http://www.php.net/) > > > >To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- Mike Flynn - Burlington, VT -- > > > mike @ mikeflynn.net > > > http://www.mikeflynn.net/ > > > home=>work=>home=>store=>home [adbusters] > > > > > > > > > > >-- > >PHP Windows Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php > > > -- Mike Flynn - Burlington, VT -- > mike @ mikeflynn.net > http://www.mikeflynn.net/ > home=>work=>home=>store=>home [adbusters] > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php