In September 1939 Hofman fled from the Nazi invasion, mainly as a result of hiding Czech refugees (including later President, Ludvík Svoboda). Escaping the German Nazis he and his wife found themselves on the part of the Polish territory invaded by the Soviet Red Army after 17 September 1939. He managed to avoid Soviet captivity, though in Pomorzany he witnessed Polish soldiers being deported to camps inside Soviet Russia, among them officers sent to Kozelsk. He reportedly "showed the Polish POWs a lot of compassion and tirelessly painted their portraits on small pieces of cardboard. The portraits were then to be sent to their families." On all accounts it is then that he befriended Zdzisław Peszkowski, who on the day before the transport to Kozelsk left in Hofman's care the regiment's money. According to Hofman's biographical notes, he managed to join the soldiers of the Czechoslovak Legion and with them travelled through Ternopil, Istambul, Haifa and Tel-Aviv to Jerusalem and Palestine, which is where he spent the remainder of the war. In 1942, he published a book of poetry called "Through Darkness to Freedom".