We extend a previously proposed rotation and truncation scheme to optimize quantum Anderson impurity calculations with exact diagonalization [PRB 90, 085102 (2014)] to density-matrix renormalization group (DMRG) calculations. The method reduces the solution of a full impurity problem with virtually unlimited bath sites to that of a small subsystem based on a natural impurity orbital basis set. The later is solved by DMRG in combination with a restricted-active-space truncation scheme. The method allows one to compute Greens functions directly on the real frequency or time axis. We critically test the convergence of the truncation scheme using a one-band Hubbard model solved in the dynamical mean-field theory. The projection is exact in the limit of both infinitely large and small Coulomb interactions. For all parameter ranges the accuracy of the projected solution converges exponentially to the exact solution with increasing subsystem size.