C quick start for the Windows Document Scanner SDK
Build a lightweight document scanner in C for Windows.
Install prerequisites
Install a C toolchain with CMake (for example, Visual Studio Build Tools and CMake) and ensure cmake is available in your terminal.
Project layout
Create a minimal project:
mkdir document-quickstart-c
cd document-quickstart-c
ni CMakeLists.txt -ItemType File
ni main.c -ItemType File
CMakeLists
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()
if(NOT SCANBOTSDK_ARCHITECTURE MATCHES "^(x64|x86)$")
message(FATAL_ERROR "Set -DSCANBOTSDK_ARCHITECTURE=x64 or -DSCANBOTSDK_ARCHITECTURE=x86")
endif()
set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}/scanbotsdk" CACHE PATH "Scanbot SDK directory")
find_program(TAR_PATH tar REQUIRED)
if(NOT EXISTS "${SCANBOTSDK_DIR}/include" OR NOT EXISTS "${SCANBOTSDK_DIR}/lib")
set(TARBALL "scanbotsdk-${SCANBOT_SDK_VERSION}-windows-${SCANBOTSDK_ARCHITECTURE}.tar.gz")
set(URL "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOT_SDK_VERSION}/${TARBALL}")
file(DOWNLOAD "${URL}" "${CMAKE_CURRENT_BINARY_DIR}/${TARBALL}" STATUS DOWNLOAD_STATUS SHOW_PROGRESS)
list(GET DOWNLOAD_STATUS 0 DOWNLOAD_CODE)
if(NOT DOWNLOAD_CODE 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_path(ScanbotSDK_INCLUDE_DIRS NAMES ScanbotSDK.h HINTS ${SCANBOTSDK_DIR}/include)
set(ScanbotSDK_DLL "${SCANBOTSDK_DIR}/lib/scanbotsdk.dll")
set(ScanbotSDK_IMPORT_LIBRARY "${SCANBOTSDK_DIR}/lib/scanbotsdk.lib")
if(NOT EXISTS "${ScanbotSDK_DLL}" OR NOT EXISTS "${ScanbotSDK_IMPORT_LIBRARY}" OR NOT ScanbotSDK_INCLUDE_DIRS)
message(FATAL_ERROR "Could not find Scanbot SDK inside ${SCANBOTSDK_DIR}")
endif()
add_library(scanbotsdk SHARED IMPORTED)
set_target_properties(scanbotsdk PROPERTIES
IMPORTED_LOCATION "${ScanbotSDK_DLL}"
IMPORTED_IMPLIB "${ScanbotSDK_IMPORT_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}"
)
add_executable(document-quickstart main.c)
target_link_libraries(document-quickstart scanbotsdk)
add_custom_command(TARGET document-quickstart POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${ScanbotSDK_DLL}"
"$<TARGET_FILE_DIR:document-quickstart>"
)
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.
loading...
Build
mkdir build
cd build
Replace <SCANBOT_SDK_VERSION> with the version you want to install. Pick the tab that matches your target architecture.
- x64 (windows-x64)
- x86 (windows-x86)
cmake -A x64 -DSCANBOT_SDK_VERSION=<SCANBOT_SDK_VERSION> -DSCANBOTSDK_ARCHITECTURE=x64 ..
cmake --build . --config Release
cmake -A Win32 -DSCANBOT_SDK_VERSION=<SCANBOT_SDK_VERSION> -DSCANBOTSDK_ARCHITECTURE=x86 ..
cmake --build . --config Release
Run
Run the app with the path to a document image:
.\Release\document-quickstart.exe C:\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
