Back Original

LaTeX.wasm: LaTeX Engines in Browsers

Step 1: Download latest release from Github. Extract the files and put them into your webpage directory.

Step 2: Include the src tag in your page.

<script src="PdfTeXEngine.js"></script>

Step 3: Initial the engine.

const engine = new LaTeXEngine();
await engine.loadEngine();

Step 4: Load the tex files/pictures/fonts to engines.

const engine = new LaTeXEngine();
engine.writeMemFSFile("main.tex", "\documentclass{...");

Step 5: Set the main file and fire the compilation.

engine.setEngineMainFile("main.tex");
let r = await engine.compileLaTeX(); // r contains PDF binray and compilation log.