The phenomenon of multicolor afterglow emission has attracted considerable attention in information encryption, bioimaging, and sensing. Consequently, there is a growing demand for the development of multicolor afterglow and phosphorescence switching methods utilizing carbon dot (CD) materials. Herein, multicolor room-temperature phosphorescence (RTP) emission in CD-based materials (PM-CD@BA composite) was achieved by developing multiple emission centers and tuning the excitation wavelength. The color of the afterglow observed in this composite covered from the deep-blue to the green region. The experimental results reveal that under heating treatment, the CDs embedded in inorganic boric acid/B2O3 matrix materials and a rigid framework generated in the composite system effectively suppressed the nonradiative transition and promoted the RTP emission. Finally, high-resolution multilevel RTP 2D code data encryption was realized by inkjet printing technology. The developed concepts of information encryption and anticounterfeiting exhibit the significant potential of CD-based afterglow materials applied in advanced optical applications.