Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multiple page options depending on scanner source #734

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Freddy-0
Copy link

Description: This pull request introduces a better solution than the workaround in #401. Instead of creating multiple "virtual" scanners to either set --page-height or not, this implementation allows different page height variables for each source.

An example is provided in 12-recipes.md.

Different Page Height Variables for Each Source

module.exports = {
  afterConfig(config) {
    devices.forEach(device => {
      device.features['--page-height'] = {
        default: 2720,
        limits: [0, 2740]
      };
      device.features['--page-height-FB'] = {
        default: 2730,
        limits: [0, 2740]
      };
      device.features['--page-height-ADF'] = {
        default: 2740,
        limits: [0, 2740]
      };
    });
  }
};

The --page-height option will default to --page-height if neither specific option is set. Even if the default option is set, it will try to use the specific option first before falling back to the default. If you don't want to set the option for the flatbed, for example, you must not set the default option, as it will fall back to this value instead.

If the page height option should only be set for an ADF scan, use this configuration:

module.exports = {
  afterConfig(config) {
    devices.forEach(device => {
      device.features['--page-height-ADF'] = {
        default: 2740,
        limits: [0, 2740]
      };
    });
  }
};

The drawback is that the user might have to set a few more variables, but it should not break any current config. The web scan works pretty flawlessly with the device.features[].default value. If someone wants to customize this value even further, they can provide the override values via the API.

Example: Assuming the above config with all the values set:

"params": {
  "deviceId": "net:192.168.1.154:fujitsu:fi-7260:1226591",
  "resolution": 300,
  "width": 201,
  "height": 297,
  "left": 0,
  "top": 0,
  "pageHeightADF": 2000,
  "pageHeightFB": 1700,
  "pageHeight": 1000,
  "mode": "color",
  "source": "Flatbed",
  "brightness": 0,
  "contrast": 0
},
"filters": [],
"pipeline": "Paperless PDF",
"batch": "auto",
"index": 1

This would override the corresponding value in the SANE command with the new value provided in the API.

Drawback: If the value is not specified in the device features, it cannot be overridden. So in the second config example, a user with API usage intents could only override the pageHeightADF value, as it is the only one set. Even if they provided the new pageHeightFB value via the parameters, it should be different in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant