(7)Where a witness fails to attend at the trial of an action or to remain in attendance in accordance with the requirements of a Summons to Witness served upon him, and the presence of that witness is material to the conduct of the action, the trial judge may, by his Warrant (Form 55B) directed to any sheriff or other peace officer in New Brunswick, cause the witness to be apprehended anywhere within New Brunswick and forthwith brought before the court. Upon being apprehended, he may be detained in custody until his presence as such witness is no longer required, or released on such terms as may be just, and he may be ordered to pay the costs arising out of his failure to attend or remain in attendance.