If you want to create a company yourself without a brazilian partner I really don't know exactly how it works, probably not dificult but you will have to ask at the Brazilian embassy in your country, they can tell you how... or you can use service of a company like this below, ask them if they create companies in Brazil too.
http://www.csr-corporation.com/en/offshore.html
But when you want to create a company with a Brazilian partner you only go to the brazilian embassy in your contry, ask for a CPF card, after one month they will give you the card, after this you send to your brazilian partner notarized copy of your CPF card and passport, probably he will send you back some papper to sign that you will have to send back to him. Them after 1 or 2 months you have a company in Brazil.
Fees are low... probably around 150 or 200 USD.
As you see, it only takes time a patience!
Regards!