Sample code for 30+ languages & platforms
Node.js

Load Entire File into BinData

Demonstrates how to load an entire file into a BinData object.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var fac = new chilkat.FileAccess();

    success = fac.OpenForRead("qa_data/pdf/sample.pdf");
    if (success == false) {
        console.log(fac.LastErrorText);
        return;
    }

    var bd = new chilkat.BinData();
    var maxBytesToRead = 99999999;
    success = fac.FileReadBd(maxBytesToRead,bd);
    if (success == false) {
        console.log(fac.LastErrorText);
        return;
    }

    fac.FileClose();

    //  The bd object contains the file data...
    success = bd.WriteFile("qa_output/sample.pdf");

}

chilkatExample();