* Company to take pretax charge of $1.7 bln in fiscal 2012
* Q2 revenue down 3 pct
* Shares up 11 pct after hours
SAN FRANCISCO, May 23 (Reuters) - Hewlett Packard Co plans to lay off roughly 27,000 employees or about 8 percent of its workforce over the next couple of years to jumpstart growth and save up to $3.5 billion annually, sending its shares 11 percent higher.
The company said the layoffs would be made mainly through early retirement and would generate annual savings of $3 billion to $3.5 billion as it exits fiscal year 2014, when the layoffs are expected to the completed.
The world's No. 1 personal computer maker, which employs more than 300,000 people globally, also said on Wednesday that it had a 31 percent decline in second-quarter profit and a 3 percent decline in revenue, compared with a year ago.
The results, however, were better than Wall Street expectations.
Layoffs "adversely impact people's lives, but in this case, they are absolutely critical to the long-term health of the company," Chief Executive Meg Whitman said.
"This is broad based," she said in an interview. "By design, it will touch all of HP."
Whitman said a third of the layoffs would be in the United States. The company will take a pretax charge of $1.7 billion in fiscal 2012 related to the layoffs.
Whitman plans to boost spending on research and development, especially in printing and PCs, with the savings from the cost cuts.
Sterne Agee analyst Shaw Wu said the quarter was surprisingly strong for HP, which had missed its own forecast most quarters in the last 18 months and prior to Whitman taking over as CEO.
"Everyone expected a miss, given what Dell said," Wu said. "It looks like HP is regaining its footing."
Dell shares on Wednesday plunged 17 percent following weaker than expected results and a disappointing revenue forecast spurred fears that global tech spending is weakening faster than anticipated.
HP itself has been trying to move past the internal upheaval that marked 2011, including the departure of two chief executives.
Whitman, a veteran Silicon Valley executive who took the top job last September, has been trying to turn the company around.
Whitman said both business leaders and consumers in Europe were worried about the region's economy, which is hurting HP's business. She warned that the European debt crisis was a big "headwind" the company was facing.
HP reported second-quarter net income of $1.59 billion, or 80 cents a share, compared with $2.3 billion, or $1.05 a share, a year ago. Revenue of $30.69 billion was down 3 percent compared with the same period last year.
Excluding after-tax costs for amortization, restructuring charges and acquisition-related charges, HP said it earned 98 cents a share, compared with analysts' average estimate of 91 cents, according to Thomson Reuters I/B/E/S.
TABLET LAUNCH FOR HOLIDAY
Whitman, who has been at the helm for six months, said the company also plans to launch tablets -- for both consumers and corporations -- later this year.
"We will have a Windows 8 tablet for the holiday," she said.
This would be HP's second attempt in the tablet market. HP killed its previous WebOS-based TouchPad tablet last year after just seven weeks on store shelves, citing poor demand.
Whitman also said HP's acquisition of British software company Autonomy for over $11 billion is facing challenges, and results in the division fell short of HP's expectations.
HP has moved the division under its chief strategy officer Bill Veghte. Autonomy founder Mike Lynch will be leaving the company.
Results from HP's other divisions were also weak.
Sales from the personal systems group, encompassing PCs, were flat with a decline in sales to consumers offsetting revenue from commercial clients.
Revenue from its bread-and-better printing group, which is being merged with the PC group, fell 10 percent after weak consumer and corporate demand.
"We improved the channel inventory to within an acceptable range," Whitman said on a conference call, referring to the printing group. "However, we continue to face a weak demand environment."
Sales of enterprise servers, storage and networking equipment fell 6 percent.
HP shares rose to $22.35 after hours after ending down 3.2 percent at $21.08.