Hartman was elected as a Republican to the Sixty-second Congress. He was unsuccessful as a candidate for reelection in 1912, and for election in 1914. He resumed his former mining and banking pursuits at Hollidaysburg. He was a delegate to the Republican National Conventions in 1908, 1924, and 1928. He died in Hollidaysburg. Interment was in Presbyterian Cemetery.