Data upload via external file like the json,csv? #376
-
Hi again, Greetings. I would like to know if it is possible to upload the data via an external file like json, csv etc as it is supported by the typst? If it does not already but there is a way to achieve this, please let me know. Thanks for such an amazing library and your support, friend. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, you could add files to your access model, which can then get read by typst compiler. The access model refers to You can also use the typst.ts/packages/typst.ts/src/compiler.mts Lines 69 to 95 in 4ef85dc The Example usage: const encoder = new TextEncoder();
// add a json file (utf8)
compiler.mapShadow('/assets/data.json', encoder.encode(jsonData));
// remove a json file
compiler.unmapShadow('/assets/data.json');
// clean up all shadow files (Note: this function will also clean all files added by `addSource`)
compiler.resetShadow();
// add an image file
const pngData = await fetch(...).arrayBuffer();
compiler.mapShadow('/assets/tiger.png', new Uint8Array(pngData)); |
Beta Was this translation helpful? Give feedback.
Hi, you could add files to your access model, which can then get read by typst compiler. The access model refers to
typst.ts/packages/typst.ts/src/options.init.mts
Line 267 in 4ef85dc
You can also use the
{map,unmap,reset}Shadow
function to manipulate any text or binary file data for typst compiler. They will shadow the file access from provided access model directly in memory.typst.ts/packages/typst.ts/src/compiler.mts
Lines 69 to 95 in 4ef85dc