async beforeProcess(buffer) {
        // we have to new Go() and create a new instance each time
        // because there are states in the go obj that prevent it from running multiple times
        this.go = new Go();

        if(!this.compiledModule) {
            let result = await WebAssembly.instantiateStreaming(fetch("pdfcpu.wasm"), this.go.importObject);
            console.log("wasm module compiled!")
            this.compiledModule = result.module; // cache, so that no need to download next time process is called
            this.instance = result.instance;
        } else {
            this.instance = await WebAssembly.instantiate(this.compiledModule, this.go.importObject);
        }

        await this.fs.writeFileAsync('/test.pdf', Buffer.from(buffer));
        let contents = await this.fs.readFileAsync('/test.pdf');
        console.log(contents);
    }
// Write input to /test.pdf in browser fs
Write input to /test.pdf in browser fs
Write input to / test . pdf in browser fs
async beforeProcess(buffer) {
        this.go = new Go();
        if(!this.compiledModule) {
            let result = await WebAssembly.instantiateStreaming(fetch("pdfcpu.wasm"), this.go.importObject);
            console.log("wasm module compiled!")
            this.compiledModule = result.module; 
            this.instance = result.instance;
        } else {
            this.instance = await WebAssembly.instantiate(this.compiledModule, this.go.importObject);
        }
        await this.fs.writeFileAsync('/test.pdf', Buffer.from(buffer));
        let contents = await this.fs.readFileAsync('/test.pdf');
        console.log(contents);
    }
async beforeProcess ( buffer ) { this . go = new Go ( ) ; if ( ! this . compiledModule ) { let result = await WebAssembly . instantiateStreaming ( fetch ( "pdfcpu.wasm" ) , this . go . importObject ) ; console . log ( "wasm module compiled!" ) this . compiledModule = result . module ; this . instance = result . instance ; } else { this . instance = await WebAssembly . instantiate ( this . compiledModule , this . go . importObject ) ; } await this . fs . writeFileAsync ( '/test.pdf' , Buffer . from ( buffer ) ) ; let contents = await this . fs . readFileAsync ( '/test.pdf' ) ; console . log ( contents ) ; }
Write input to /test.pdf in browser fs
Write input to / test . pdf in browser fs
// we have to new Go() and create a new instance each time // because there are states in the go obj that prevent it from running multiple times // cache, so that no need to download next time process is called