Renaming $f(x) = u'(x)$, the equation becomes $-Df'(x) + \frac{1}{2}f(x) = 1$, which is an inhomogeneous first-order linear ODE with constant coefficients.
The homogeneous solution is given by $-Df_h'(x) + \frac{1}{2}f_h(x) = 0$, which leads to $f_h(x) = Ae^{x/2D}$, with $A$ a constant. As the source term is constant, the particular solution can be guessed to be a constant itself, i.e. $f_p(x) = \alpha$, hence $-D\cdot0 + \frac{1}{2}\alpha = 1$ and $f_p(x) = 2$. One has finally $f(x) = f_h(x) + f_p(x) = Ae^{x/2D} + 2$.
We get $u(x)$ by integrating this last solution, i.e. $u(x) = 2DAe^{x/2D} + 2x + B$, with $B$ another constant. The boundary conditions imply :
$$
\begin{cases}
u(0) = 0 = 2DA + B \\
u(\pi) = 0 = 2DAe^{\pi/2D} + 2\pi + B
\end{cases}
\quad\Longrightarrow\quad
\begin{cases}
A = \frac{\pi}{D}\frac{1}{1-e^{\pi/2D}} \\
B = -2DA = -\frac{2\pi}{1-e^{\pi/2D}}
\end{cases}
$$