Sample code for 30+ languages & platforms
Ruby

Load Entire File into BinData

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

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

fac = Chilkat::CkFileAccess.new()

success = fac.OpenForRead("qa_data/pdf/sample.pdf")
if (success == false)
    print fac.lastErrorText() + "\n";
    exit
end

bd = Chilkat::CkBinData.new()
maxBytesToRead = 99999999
success = fac.FileReadBd(maxBytesToRead,bd)
if (success == false)
    print fac.lastErrorText() + "\n";
    exit
end

fac.FileClose()

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