C quick start for the Linux Document Scanner SDK
Build a lightweight document scanner in C for Linux.
Install prerequisites
Install a C compiler, CMake, and wget:
sudo apt update
sudo apt install -y cmake build-essential wget
Project layout
Create a minimal project:
mkdir -p document-quickstart-c
cd document-quickstart-c
touch CMakeLists.txt main.c
CMakeLists
CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(scanbot_document_quickstart C)
set(CMAKE_C_STANDARD 11)
if(NOT SCANBOT_SDK_VERSION)
message(FATAL_ERROR "You must set -DSCANBOT_SDK_VERSION=<version>")
endif()
set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}/scanbotsdk" CACHE PATH "Scanbot SDK directory")
if(NOT EXISTS "${SCANBOTSDK_DIR}/include" OR NOT EXISTS "${SCANBOTSDK_DIR}/lib")
find_program(WGET_PATH wget REQUIRED)
find_program(TAR_PATH tar REQUIRED)
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES ".*(arm|aarch64).*")
set(SCANBOTSDK_ARCHITECTURE "aarch64")
else()
set(SCANBOTSDK_ARCHITECTURE "x86_64")
endif()
set(TARBALL "scanbotsdk-${SCANBOT_SDK_VERSION}-linux-${SCANBOTSDK_ARCHITECTURE}.tar.gz")
set(URL "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOT_SDK_VERSION}/${TARBALL}")
execute_process(
COMMAND ${WGET_PATH} -q -O "${TARBALL}" "${URL}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE WGET_RES
)
if(NOT WGET_RES EQUAL 0)
message(FATAL_ERROR "Failed to download ${URL}")
endif()
file(MAKE_DIRECTORY "${SCANBOTSDK_DIR}")
execute_process(
COMMAND ${TAR_PATH} -xzf "${TARBALL}" -C "${SCANBOTSDK_DIR}" --strip-components=1
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE TAR_RES
)
if(NOT TAR_RES EQUAL 0)
message(FATAL_ERROR "Failed to extract ${TARBALL}")
endif()
endif()
find_library(ScanbotSDK_LIBS NAMES scanbotsdk libscanbotsdk.so HINTS ${SCANBOTSDK_DIR}/lib)
find_path(ScanbotSDK_INCLUDE_DIRS NAMES ScanbotSDK.h HINTS ${SCANBOTSDK_DIR}/include)
add_library(scanbotsdk SHARED IMPORTED)
set_target_properties(scanbotsdk PROPERTIES
IMPORTED_LOCATION "${ScanbotSDK_LIBS}"
INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}"
)
add_executable(document-quickstart main.c)
target_link_libraries(document-quickstart scanbotsdk m pthread)
Initialize the Scanbot SDK
Before using any feature of the Scanbot SDK, initialize the SDK with your license key.
scanbotsdk_init_params_t params = (scanbotsdk_init_params_t){0};
params.license_key = (char *)"<SCANBOTSDK-LICENSE-KEY>";
params.writeable_path = ".";
scanbotsdk_error_code_t ec = scanbotsdk_initialize(¶ms);
Scan a document image
The following snippet scans a document from an image.
scan document from ImageRef
loading...
Build
mkdir -p build
cd build
cmake -DSCANBOT_SDK_VERSION=<SCANBOT_SDK_VERSION> ..
make -j
Run
Run the app with the path to a document image:
./document-quickstart /path/to/document_image.jpg
Get in touch
If you need further information or are interested in licensing the Scanbot SDK, please get in touch with our solution experts.
Scanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
