Can I get Steam Trading Cards from game demos?
No. If they allowed this, it would be abused by people with multiple accounts.
For this same reason, you cannot get cards for free-to-play games without purchasing something first:
What about free to play games like Team Fortress 2 or Dota 2?
Free to play games drop game cards based on your in-game purchasing. For every $9 USD spent (approximate) since the start of the Steam Trading Card Beta, you will earn one card drop.
No. I tried with the Kerbal Space Program demo and didn't get any cards.
UPDATE
You also are unable to get cards from "Free Weekend" type games. ORION: Dino Horde let users play the game for free for an entire week. I played for over 3 hours and received no cards. The badge showed up on my "Badges" list but said "No Card Drops Remaining".
Essentially, to get card drops you must either purchase a game or, for Free-To-Play games, purchase items from the game store.