We study analytically a model of a two-dimensional partially directed flexible or semiflexible polymer, attached to an attractive wall which is perpendicular to the preferred direction. In addition, the polymer is stretched by an externally applied force. We find that the wall has a dramatic effect on the polymer. For wall attraction epsilon1 smaller than the nonsequential nearest-neighbor attraction epsilon, the fraction of monomers at the wall is zero and the model is the same as that of a polymer without a wall. However, for epsilon1 greater than epsilon, the fraction of monomers at the wall undergoes a first-order transition from unity at low temperature and small force, to zero at higher temperatures and forces. We present phase diagram for this transition. Our results are confirmed by Monte Carlo simulations.