Ramos, from Laurel, Maryland, is also said to have had a long-running feud with the Capital Gazette newspaper, it says.
First responders attended to the emergency call on Thursday within 60 to 90 seconds and quickly apprehended Ramos, described as being in his late 30s, who was found hiding under a desk with a gun discarded nearby, police say.
The attack came after a series of social media threats were made to the paper, police say.
Ramos is alleged to have entered the building and “looked for his victims”, throwing smoke grenades and firing bullets, Anne Arundel County Acting Police Chief William Krampf said.
“This person was prepared today to come in, this person was prepared to shoot people. His intent was to cause harm,” Krampf said.
Phil Davis, a crime and courts reporter at the newspaper, tweeted that the gunman shot out the glass door to the office and fired into the newsroom, sending people scrambling under desks.
“A single shooter shot multiple people at my office, some of whom are dead,” he wrote.
Davis added: “There is nothing more terrifying than hearing multiple people get shot while you’re under your desk and then hear the gunman reload.”
Law enforcement officials said the suspect had mutilated his fingers in an apparent attempt to make it harder to identify him with another saying investigators had used facial recognition technology to identify him.
The shooting comes amid months of verbal and online attacks on the “fake news media” from politicians including US President Donald Trump has prompted New York City police to immediately tighten security at news organisations.
White House spokeswoman Lindsay Walters said: “There is no room for violence, and we stick by that. Violence is never tolerated in any form, no matter whom it is against.”
The gunman is believed to have used a shotgun, a US official who did not want to be named said.
“The shooter has not been very forthcoming, so we don’t have any information yet on motive,” Anne Arundel County Executive Steve Schuh said.
“To my knowledge, there was no verbal aspect to the incident where he declared his motives or anything else, so at this point we just don’t know.”
Krampf confirmed five deaths and said two people had superficial wounds. Authorities had said earlier that several people were gravely wounded.
The newspaper is part of Capital Gazette Communications, which also publishes the Maryland Gazette and CapitalGazette.com.
In an interview with The Capital Gazette’s online site, Davis said it “was like a war zone” inside the newspaper’s offices – a situation that would be “hard to describe for a while.”
“I’m a police reporter. I write about this stuff – not necessarily to this extent, but shootings and death – all the time,” he said. “But as much as I’m going to try to articulate how traumatising it is to be hiding under your desk, you don’t know until you’re there and you feel helpless.”
We value local independent journalism. We hope you do too.
InDaily provides valuable, local independent journalism in South Australia. As a news organisation it offers an alternative to The Advertiser, a different voice and a closer look at what is happening in our city and state for free. Any contribution to help fund our work is appreciated. Please click below to become an InDaily supporter.