escl-scan


Copr build status Travis-CI build status dependency status

Example:

```rust extern crate esclscan; extern crate serdexml_rs;

fn main() { // Define variables... let scannerbasepath = "192.168.2.5"; // IP or mDNS (for example "Printer.local." to printer let scanresolution = 300; // DPI let destinationfile = "output.jpg"; // I think you already know what it is for

// Get scanner capabilities...
let scanner_capabilities = escl_scan::get_scanner_capabilities(&scanner_base_path);

// Create scan settings...
let scan_settings: escl_scan::structs::ScanSettings = escl_scan::structs::ScanSettings {
    version: "2.6".to_string(),
    scan_regions: escl_scan::structs::ScanRegion {
        x_offset: 0,
        y_offset: 0,
        width: scanner_capabilities.platen.platen_input_caps.max_width,
        height: scanner_capabilities.platen.platen_input_caps.max_height,
        content_region_units: "escl:ThreeHundredthsOfInches".to_string(),
    },
    input_source: "Platen".to_string(),
    color_mode: "RGB24".to_string(),
    x_resolution: scan_resolution,
    y_resolution: scan_resolution,
};

// Send scan request...
let request_body = serde_xml_rs::to_string(&scan_settings).unwrap();
let scan_response = escl_scan::get_scan_response(scanner_base_path, request_body);

// Get scan url...
let download_url = format!(
    "{}/NextDocument",
    scan_response
        .headers()
        .get("location")
        .unwrap()
        .to_str()
        .unwrap()
);

// Download scan...
escl_scan::download_scan(&download_url, destination_file);

} ```