PHP Nuisance: How to Stream PDF Files

If you’ve ever tried to stream a PDF file in PHP, you know how incredibly annoying it is to get it working across all browsers. In fact, the maintainer of HtmlToPdf didn’t have an official response on the topic of streaming PDF data to the browser. It only worked most of the time. When it fails, the page loads the data, but nothing actually shows up and your PDF reader will not fire.

The very short explanation is that IE ignores certain content type headers and tries to guess what a file is based on its content. This is a problem in some situations when IE guesses wrong. God, IE is so dumb because it tries to be too smart. Don’t you hate people like that?

Anyway, to get it to work, you have to hack at it. There are added complications to this when you are using HTTPS instead of HTTP.

After we spent a few hours today at work trying to solve this problem, I remembered I had done this before. I dug up some old code and found the solution:

$filename = ‘yourfilename.pdf’;
header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: public”);
header(“Content-Description: File Transfer”);
header(“Content-Type: application/pdf”);
header(“Content-Disposition: attachment; filename=$filename”);
header(“Content-Transfer-Encoding: binary”);
// echo the pdf raw binary data here

As far as I know, this works in every browser. All you Googlers: Enjoy! 😉

Leave a comment if this worked! 🙂

The Down Side of Getting on Digg and Having Tons of Readers

Ever since I got Dugg and what not, I have had a ton more readers. I’ve gotten about 1,000 visitors a day now, many of which subscribed (hurray!). But my new boo-hoo “I’m not a princess” moment came when I looked at my logs for the month:

a mountain in a sea of no visitors

Reminds me of a mountain in the middle of a really barren, really flat desert. I shouldn’t complain, especially since this blog is 100% for-fun anyway.

Well, the real down side to having hundreds of readers is that I now have an implicit responsibility to update on a daily basis. 😉

If PS3 Broke Records in UK Why is it so Cheap on UK eBay?

Today’s post is about the PS3. I find the PS3 to be an interesting product because of its relative success despite its pricing and feature set that is contrary to the customer’s desires. In short, it has features most customers don’t want (Blu-Ray) and because of these features, it costs a ton more.

So imagine my surprise when the media started reporting that the PS3 sold out in Europe and, in fact, broke sales records in the UK.

I remember launch day in the US: every PS3 in sight was sold out and the Wiis barely ran out of stock. But then it was only a few weeks before demand revealed itself: everybody bought a PS3 so they could scalp it to the hardcore fans who didn’t have one yet. As a result, the PS3 aftermarket quickly died and the eBay market followed it. Soon, people were selling them for a loss!

And I remember Japan’s launch, when people were paying Chinese immigrants to stand in line and buy PS3s so they could sell them later. In fact, the story goes that the first person to ever buy a PS3 later walked from the store to a nearby parked car and gave it to his “boss.” It seems to me like the PS3 launch hype is largely due to scalpers.

So what about the UK? With all this record breaking nonsense, UK eBay must be booming, right? Here’s what I noticed after looking at 1423 closed PS3 auctions in the UK:

  • High prices (30% markup or more) were commanded by auctions that happened prior to March 25th (launch). This makes sense.
  • Only 55 closed auctions went or asked for a price above retail (£600).
  • Most that sold for a profit went for £650 (8% markup).
  • At £599 (retail), there were 95 auctions that went without any bids, three auctions for the PS3 that sold, and five auctions for the PS3 plus 3 games that sold.
  • There are countless pages of auctions below retail price going unsold (requires eBay login). £450 for a £599 console that came out less than a week ago? (see image below)
  • In contrast, searches for the Wii show approximately half of all auctions (maybe 60%) closed with a sale. Prices ranged a lot due to bundling, but a vanilla Wii was selling for approximately £300 (65% markup). In fact, at the £300 range (requires login), virtually every auction closed with a sale. And at the £250 range (requires login), the auctions had double digit bids.

check out those buy it now prices!I am not doing this to be scientific, but it’s a stark difference from the PS3 opening week in the US. Auctions ranged around $900 for the 60GB model, a 50% markup. I urge others to go confirm my observations. eBay is possibly the single best product demand barometer of our time. I know the PS3 broke records in UK, but then why isn’t the UK eBay demand following these figures? Is there low demand, except from scalpers?

If I’m wrong, the PS3 will continue to sell out in Europe and give Sony the boost it needs. But if I’m right, you should start seeing the negative “too much stock” stories in about 2 weeks when the eBay market reality sends thousands of scalpers back to the store to get refunds.

At the very least, someone explain all of these “buy it now” auctions that are set below the retail price.