Digital holographic microscopy (DHM) has been widely applied for the topography measurement of microscopic specimen. A total surface fitting method based on Zernike polynomials is presented to remove aberrations in DHM, in which Zernike polynomial coefficients enable to provide quantitative measurement of primary aberrations. The phase free of aberrations is obtained by subtracting out the surface fitting result from the reconstructed phase. The method carries out the total phase aberrations compensation automatically by only one hologram, instead of knowing the physical parameters of optical setup and the aberration mathematical model in advance. The optical system of off-axis DHM is set up and the experiment results are given. Compared with the double-exposure method, the Zernike surface fitting method obtains better phase information owing to removing residual tilt aberration.