The Swedish author Astrid Lindgren (1907-2002) is beloved around the world for her best-selling children’s books (most notably “Pippi Longstocking”), but “Becoming Astrid” doesn’t primarily concern itself with how she got to be a famous writer. Centering on the protagonist’s late teens and early 20s – when she was still known by her maiden name, Ericsson, the engrossing film by Danish director Pernille Fischer Christensen tells the story of Astrid’s affair with a married employer, the editor of the small-town newspaper where the 19-year-old had taken a job as a secretary and sometime reporter.

The resulting pregnancy and the birth of her son, Lars – who was sent to Denmark for several years, where he was looked after by a foster mother – forms the spine of this captivating story, which is both a feminist coming-of-age tale and a romance, though not the kind you think. Although much of the film concerns Astrid’s efforts to reunite with her little boy and marry his father (Henrik Rafaelson), the real love story takes place between Astrid and her child, who must remain apart from her until she can afford to raise him herself. Complications and delays arise when her married lover is unable to obtain a quick divorce.

This familiar-sounding melodrama works because of the extraordinary performance, in the title role, by Alba August, a young actress whose every emotion is made manifest, like passing clouds or a burst of sunshine, on her uncannily expressive face. This being the late 1920s, when an illegitimate child was a scandal indeed, Astrid is an usually confident, convention-flouting free spirit, given her fierce determination to keep and raise her son, married or not.

“Becoming Astrid” is structured within an unusual framing device. The film begins in 1987, with an actress (Maria Fahl Vikander) playing the writer on her 80th birthday, opening cards and letters from young fans of her books. Those messages – which call attention to Lindgren’s special affinity for the psychology of children, and her books’ spirit of youthful resilience and independence even through tragedy – are read aloud at various points throughout the film, underscoring the connection between the facts depicted on-screen and Lindgren’s inspirational fiction. At times, this linkage feels overly on-the-nose, but the gimmick ultimately works more than it doesn’t.

Pippi Longstocking has sometimes been called an icon of feminist girl-power. If “Becoming Astrid’ makes anything clear, it’s that the character’s creator was something of one herself.