Magnetic soft materials (MSM) show excellent potential in soft robotics, biomedicine, and sensors because of their excellent magnetic response, reversible deformation, and controlled motion. A hard magnetic soft material (HASM) that can be obtained by adding hard magnetic particles to a soft material matrix. By programing the spatial magnetization profile of the HASM object and manipulating the driving magnetic field, it exhibits excellent shape manipulation performance with unconstrained, reversible deformation transformation and controlled motion. In this study, a HASM ink consisting of hard magnetic NdFeB particles with a soft silicone rubber matrix was prepared. A 4D printing strategy using 3D injection printing technology combined with origami magnetization technology is used to fabricate 3D structured HASM objects for flexible shape programmability. A variety of programed shapes of HASM straight beams with bionic fish tails were fabricated by 4D printing strategy. The HASM straight beam is driven by the magnetic field, which can quickly realize the transformation and change of the preset shape as well as the shape of the HASM beam. The HASM bionic fish tail can swing rapidly under the action of the driving magnetic field. It shows a broad potential in the field of soft and bionic robots.