Sample code for 30+ languages & platforms
Chilkat2-Python

Load Entire File into BinData

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

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

fac = chilkat2.FileAccess()

success = fac.OpenForRead("qa_data/pdf/sample.pdf")
if (success == False):
    print(fac.LastErrorText)
    sys.exit()

bd = chilkat2.BinData()
maxBytesToRead = 99999999
success = fac.FileReadBd(maxBytesToRead,bd)
if (success == False):
    print(fac.LastErrorText)
    sys.exit()

fac.FileClose()

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