Lexmark, best known for its inkjet printers, announced Tuesday that it was completely exiting the business to focus on its more profitable imaging and software businesses.

The company had been slowly disengaging itself as the business began to be a drag on its bottom line. While Chief Executive Paul Rooke called the decision "difficult," he also said it was necessary for profitability.

Shares of Lexmark (LXK) rallied nearly 20% Tuesday, before easing to $22.31, still up 17%. The stock has taken a beating this year, with shares down 33% since January.

Lexmark expects to eliminate all of its inkjet development -- and will sell equipment and lay off 1,700 workers by the end of 2013. The company plans to close its inkjet supplies manufacturing facility in the Philippines by the end of 2015.

The end result: cost savings of $85 million in 2013 , rising to $95 million (on an annualized basis) in 2015. Lexmark says it will continue to provide service, support and supplies for its "inkjet installed base."

The plan will cost Lexmark $160 million, with $110 million this year.

Good news for investors: Lexmark also plans to buy back an additional $100 million shares through the end of the year, a move the company says will bring its total shareholder return to more than $500 million since mid-2011.

Lexmark isn't the only struggling printer maker. Earlier this month, Hewlett-Packard (HPQ), the world's top PC maker, reported a 15% decline in consumer hardware revenue, with a 15% decline in printer units.