Sample code for 30+ languages & platforms
JavaScript

Load Entire File into BinData

Demonstrates how to load an entire file into a BinData object.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var fac = new CkFileAccess();

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

var bd = new CkBinData();
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");