I think that what you are asking is not completely a mathematical problem but a physical trick...
Since I think that you got stuck around eq. (19) of the document you uploaded, I'll try to explain what's going on there.
The aim is to expand our state $|\psi \rangle$ in terms of our basis vector $|x\rangle$.
We can rewrite the state $|\psi\rangle$ in the following way
$$|\psi\rangle = \hat{1}|\psi\rangle $$
At this point you only have only multiplied your state by an identity matrix. Then using (18) that is nothing but a vector identity, you can rewrite the product as
$$\sum_k |x\rangle\langle x||\psi\rangle $$
but since in general, a Hilbert space has infinite dimension, we are allowed to consider the integral instead of the sum and then we have
$$|\psi\rangle = \int |x\rangle\langle x||\psi\rangle dx $$
and defining (here's the trick!) $ \psi(x) = \langle x|\psi \rangle$ we finally get the equivalence
$$|\psi\rangle = \int \psi(x)|x\rangle dx $$
This $\psi(x) $ is nothing but our familiar wavefunction.
In the present language, $\psi(x) $ are the coordinates of the our state $|\psi\rangle$ in the $|x\rangle$ basis, since you're only projecting your function on the element of the basis!