4. As shown in Figure 2, given the ellipse $\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1$ $(a>b>0)$, the line $l$ is tangent to the ellipse at point $P$, and intersects the positive $x$-axis and the positive $y$-axis at points $A$ and $B$, respectively. If $|P A|=b$, then $|P B|$ is ( ).
(A) $a$
(B) $\sqrt{a b}$
(C) $\sqrt{a^{2}-b^{2}}$
(D) $\sqrt{a^{2}+b^{2}}$
4.A.

It is known that the point of tangency $P\left(x_{0}, y_{0}\right)$ is in the first quadrant. Then the equation of the tangent line $l$ is $\frac{x_{0} x}{a^{2}}+\frac{y_{0} y}{b^{2}}=1$.
By setting $y=0, x=0$, we get $A\left(\frac{a^{2}}{x_{0}}, 0\right), B\left(0, \frac{b^{2}}{y_{0}}\right)$.
From $|P A|=b$, we have $\left(\frac{a^{2}}{x_{0}}-x_{0}\right)^{2}+y_{0}^{2}=b^{2}$, which means $\left(\frac{a^{2}}{x_{0}}-x_{0}\right)^{2}=\frac{b^{2}}{a^{2}} x_{0}^{2}$.
Since $\frac{a^{2}}{x_{0}}>x_{0}>0$, we have
$$
\frac{a^{2}}{x_{0}}-x_{0}=\frac{b}{a} x_{0} \Rightarrow x_{0}^{2}=\frac{a^{3}}{a+b} \text {. }
$$

Then $y_{0}^{2}=\frac{b^{2}}{a^{2}}\left(a^{2}-x_{0}^{2}\right)=\frac{b^{2}}{a^{2}}\left(a^{2}-\frac{a^{3}}{a+b}\right)$ $=\frac{b^{3}}{a+b}$.
Therefore, $|P B|=\sqrt{x_{0}^{2}+\left(\frac{b^{2}}{y_{0}}-y_{0}\right)^{2}}$
$=\sqrt{x_{0}^{2}+\frac{b^{4}}{y_{0}^{2}}-2 b^{2}+y_{0}^{2}}$
$=\sqrt{\frac{a^{3}}{a+b}+\dot{b}(a+b)-2 b^{2}+\frac{b^{3}}{a+b}}=a$.