docx
    Preparing search index...

    Function measureWithPretext

    • Measures text with Pretext, in the fonts the page has, for laying out a document's pages in a browser. Pretext needs a canvas to measure with, an OffscreenCanvas or a page's, so it doesn't work in Node.

      Load the fonts first, such as with document.fonts.load("11pt Calibri"): until a font has loaded, the browser measures text in another, and Pretext keeps the widths it measured.

      import * as pretext from "@chenglou/pretext";
      import { estimatePageNumbersWith, measureWithPretext } from "docx/layout";

      new Document({ pageNumbers: estimatePageNumbersWith({ measureWidth: measureWithPretext(pretext) }), sections: [...] });

      Type Parameters

      • Prepared

      Parameters

      Returns MeasureWidth