  We find exact static soliton solutions for the unit spin vector field of an
inhomogeneous, anisotropic three-dimensional Heisenberg ferromagnet. Each
soliton is labeled by two integers $n$ and $m$. It is a (modified) skyrmion in
the $z=0$ plane with winding number $n$, which twists out of the plane $m$
times in the $z$-direction to become a 3D soliton. Here $m$ arises due to the
periodic boundary condition at the $z$-boundaries. We use Whitehead's integral
expression to find that the Hopf invariant of the soliton is an integer $H
=nm$. It represents a hopfion vortex. Plots of the preimages of this
topological soliton show that they are either unknots or nontrivial knots,
depending on $n$ and $m$. Any pair of preimage curves links $H$ times,
corroborating the interpretation of $H$ as a linking number. We also calculate
the exact energy of the hopfion vortex, and show that its topological lower
bound has a sublinear dependence on $H$. Using Derrick's scaling analysis, we
demonstrate that the presence of a spatial inhomogeneity in the anisotropic
interaction, which in turn introduces a characteristic length scale in the
system, leads to the stability of the hopfion vortex.
