Line integral solution of Hamiltonian PDEs