An American man fatally stabbed himself with a pair of scissors in a Taiwan courtroom Thursday during his sentencing on drug possession charges, raising questions over security failings.

The man, named as 41-year-old Tyrel Martin Marhanka, is thought to have hidden the dismantled scissors inside a magazine to get past a metal detecting door, Changhua district court said.

The court vowed to beef up its security control by adding two X-ray scanners when it moves to a new building.

There is not enough room for the scanners at its current facility, it said.

When the judge handed down a four-year prison sentence for smuggling poppy and marijuana seeds and for growing marijuana, Marhanka stabbed himself in the neck before bailiffs could stop him.

He was rushed to a hospital but emergency treatment failed to revive him.

"We deeply regret that Tyrel Martin Marhanka killed himself during the sentencing," the court said in a statement.

"He was cooperative during the investigation and the trial. His attitude was mild and he did not show any signs that he would commit suicide."

Marhanka was married to a Taiwanese woman with two children and had been living on the island for many years, according to the court.