This is really just an outline of the proof, as several of the algebraic steps have been left to the reader. Begin with a line, $\ell,$ and a point, $P(x_{1},y_{1}),$ not on the line. Let $\ell$ have the equation of standard form. \[ \left(\ell\right):\qquad ax+by+c=0 \] If we cast this equation into slope intercept form, it will be \[ y=\frac{-a}{b}x-\frac{b}{c} \] and we get the slope $-\frac{a}{b}.$ From that slope, we can take the negative reciprocal and write an equation of a line that passes through $P$ and is perpendicular to $\ell.$ We will call this line $d.$ \[ \left(d\right):\qquad y-y_{1}=\frac{b}{a}\left(x-x_{1}\right) \]
Next we will solve simultaneously $\left(\ell\right)$ and $\left(d\right)$ to get the right angle intersection point coming from $P.$ Here, the algebra has been done by Geogebra. We will name this point $E.$ \[ E:\left\{ x=\frac{-a\;b\;y_{1}-a\;c+b^{2}\;x_{1}}{a^{2}+b^{2}},y=\frac{a^{2}\;y_{1}-a\;b\;x_{1}-b\;c}{a^{2}+b^{2}}\right\} \] Use the distance formula, which we have proved from Pythagoras, to get the distance between $P$ and $E.$ \[ |P-E|=\sqrt{\left(\frac{-a\;b\;y_{1}-a\;c+b^{2}\;x_{1}}{a^{2}+b^{2}}-x_{1}\right)^{2}+\left(\frac{a^{2}\;y_{1}-a\;b\;x_{1}-b\;c}{a^{2}+b^{2}}-y_{1}\right)^{2}} \] From here to the end is all algebra. I will show a few of the steps.
This will be exactly the same scheme used for standard form. We will write an equation for a line. Then we will write an equation for the perpendicular line that goes through point $P.$ Then we will solve them simultaneously to get the intersection point. Finally, we will use the distance formula to obtain the length from $P$ to the intersection.