We can convert the integral into a direct sum by using the series expansion of the tangent:
$$
\tan^2(x)=\sum_{k=1}^{\infty}
\frac{2\,(2^{2k+2}-1)\, (2k+1)\, \zeta(2k+2)}{\pi^{2k+2}}
x^{2 k}
$$
in terms of the Riemann zeta function (or alternatively in terms of the Bernoulli numbers through $\zeta(2k+2)=\frac{(-1)^k 2^{2k+1} \pi^{2k+2} B_{2k+2}}{(2 k+2)!}$).
The integral in question becomes
$$
\int\frac{\tan^2(x)}{1+x^2}dx
=\sum_{k=1}^{\infty}
\frac{2\,(2^{2k+2}-1)\, (2k+1)\, \zeta(2k+2)}{\pi^{2k+2}}
\int\frac{x^{2 k}}{1+x^2}dx
$$
which we can integrate component-by-component,
Integrate[x^(2 k) / (1 + x^2), x]
(* (x^(1 + 2 k) Hypergeometric2F1[1, 1/2 + k, 3/2 + k, -x^2])/(1 + 2 k) *)
getting the sum
$$
\int\frac{\tan^2(x)}{1+x^2}dx
=\sum_{k=1}^{\infty}
\frac{2\,(2^{2k+2}-1)\, \zeta(2k+2)}{\pi^{2k+2}}
x^{2k+1} {_2}F_1\left(1,k+\frac{1}{2};k+\frac{3}{2};-x^2\right).
$$
This sum converges rapidly: For large $k$, $\zeta(2k+2)\approx1$ and the hypergeometric function is ${_2}F_1\left(1,k+\frac12;k+\frac32;-x^2\right)\approx\frac{1}{1+x^2}$, which makes the $k^{\text{th}}$ term approximately
$$
\frac{2\,(2^{2k+2}-1)\, \zeta(2k+2)}{\pi^{2k+2}}
x^{2k+1} {_2}F_1\left(1,k+\frac{1}{2};k+\frac{3}{2};-x^2\right)
\approx \left(\frac{2x}{\pi}\right)^{2k+2}\frac{2}{x(1+x^2)},
$$
which becomes exponentially smaller with $k\to\infty$ as long as $|x|<\frac{\pi}{2}$.
Let's try out the case of definite integration over $[0,\frac{\pi}{4}]$:
NIntegrate[Tan[x]^2/(1 + x^2), {x, 0, π/4}]
(* 0.1565032456995724` *)
With[{x = π/4},
Sum[2(2^(2k+2)-1) Zeta[2k+2]/π^(2k+2) x^(2k+1) *
Hypergeometric2F1[1, k+1/2, k+3/2, -x^2], {k, 20}]] // N
(* 0.1565032456994413` *)
side note on hypergeometric functions
The hypergeometric function can also be written as a Hurwitz–Lerch transcendent or as an incomplete beta function:
$$
{_2}F_1\left(1,k+\frac12;k+\frac32;z\right)
=\left(k+\frac12\right) \Phi \left(z,1,k+\frac12\right)
=\frac{k+\frac12}{z^{k+1/2}} B_z\left(k+\frac12,0\right)
$$
Of these, the Hurwitz–Lerch transcendent is probably the simplest to evaluate in practice because it reduces to a finite sum:
$$
\Phi \left(z,1,k+\frac12\right)
= \frac{2}{z^{k+1/2}}\tanh^{-1}\sqrt{z}-\sum_{s=1}^k \frac{1}{\left(k+\frac12-s\right)z^s}
$$
With this simplification the result can be written in terms of $\arctan$ and $\zeta$ only:
With[{x = π/4},
Sum[2 (-1)^k (2^(2k+2)-1) (2k+1) π^(-2k-2) Zeta[2k+2] *
(ArcTan[x] - Sum[((-1)^q x^(2q+1))/(2q+1), {q, 0, k-1}]),
{k, 20}]] // N
(* 0.1565032456994413` *)
int(-4*I*x/((x^2 + 1)^2*(exp(x*I)^2 + 1)), x)
if you can solve this, then it is solved. But none of the CAS'es I tried could solve it. $\endgroup$