In cotton fabric inkjet printing, the spreading and penetration of the ink seriously damage printing resolution and color strength. In this study, hydroxypropyl methyl cellulose (HPMC) with varying viscosity grades (6, 30, 100, 400, and 4000 mPa·s) were used for fabric pretreatment to reduce the ink spreading and penetration. The results indicated that HPMC with a high viscosity grade enhanced the ability of pretreatment paste to form a continuous HPMC film on the fiber surface. A continuous film could greatly increase the hydrophobicity of the fabric, thereby restricting the spreading and penetration of ink. Meanwhile, ink migration was also limited by the paste connected to the fibers and the swelling of the film, which was more significant at higher HPMC viscosity grades. However, the increase of the HPMC viscosity grade was not conducive to dye fixation. Additionally, HPMC with a viscosity grade of 100 mPa·s was considered a reasonable choice, which could improve printing resolution and color strength in industrial applications. This research provides a new approach for optimizing pretreatment paste to achieve high-quality printed products.