Nowadays, regulation standards regarding the injection of harmonics in the grid power supply are becoming stricter. These standards have a direct impact on the design and control of converters, especially in medium-voltage drives. To fulfil these standards, converters are designed to work with the power factor as close to unity as possible and to correct the harmonics spectrum in case of a grid power supply with multiple resonances. The preferred modulation technique for medium-voltage drives is usually selective harmonic elimination pulse width modulation. This approach requires a precise calculation of pulse patterns (switching angle vs. modulation index) with additional constraints. This research presents a new approach for the determination of optimal pulse patterns. The technique ensures the elimination of low-order harmonics and minimization of some high-order ones. The proposed technique incorporates the additional constraints regarding minimum on/off switching time (pulse duration) and ensures the continuity of pulse patterns. Optimal pulse patterns are determined with the brute force method which searches the feasible solution space by use of the Jacobian matrix null space. Determined pulse patterns are verified by the simulation and experimental measurements.