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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app-server/src/classes/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ module.exports = class Request {
if ('--page-height' in features) {
this.params.pageHeight = constrainWithFeature(data.params.pageHeight, features['--page-height']);
}
if ('--page-height-ADF' in features) {
this.params.pageHeightADF = constrainWithFeature(data.params.pageHeightADF, features['--page-height-ADF']);
}
if ('--page-height-FB' in features) {
this.params.pageHeightFB = constrainWithFeature(data.params.pageHeightFB, features['--page-height-FB']);
}
if ('--page-width' in features) {
this.params.pageWidth = constrainWithFeature(data.params.pageWidth, features['--page-width']);
}
Expand Down
14 changes: 12 additions & 2 deletions app-server/src/classes/scanimage-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,22 @@ module.exports = class ScanimageCommand {

cmdBuilder.arg('--resolution', params.resolution);

if ('pageWidth' in params) {
if ('pageWidth' in params && /ADF/.test(params.source)) {
cmdBuilder.arg('--page-width', params.pageWidthADF);
} else if ('pageWidth' in params && !/ADF/.test(params.source)) {
cmdBuilder.arg('--page-width', params.pageWidthFB);
} else if ('pageWidth' in params) {
cmdBuilder.arg('--page-width', params.pageWidth);
}
if ('pageHeight' in params) {

if ('pageHeightADF' in params && /ADF/.test(params.source)) {
cmdBuilder.arg('--page-height', params.pageHeightADF);
} else if ('pageHeightFB' in params && !/ADF/.test(params.source)) {
cmdBuilder.arg('--page-height', params.pageHeightFB);
} else if ('pageHeight' in params) {
cmdBuilder.arg('--page-height', params.pageHeight);
}

if ('left' in params) {
cmdBuilder.arg('-l', params.left);
}
Expand Down
9 changes: 7 additions & 2 deletions app-ui/src/classes/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ export default class Request {
if ('--page-height' in device.features) {
this.params.pageHeight = request.params.pageHeight || device.features['--page-height'].default;
}
if ('--page-height-ADF' in device.features) {
this.params.pageHeightADF = request.params.pageHeightADF || device.features['--page-height-ADF'].default;
}
if ('--page-height-FB' in device.features) {
this.params.pageHeightFB = request.params.pageHeightFB || device.features['--page-height-FB'].default;
}
if ('--page-width' in device.features) {
this.params.pageWidth = request.params.pageWidth || device.features['--page-width'].default;
}

}
if ('--adf-mode' in device.features) {
this.params.adfMode = request.params.adfMode || device.features['--adf-mode'].default;
}
Expand Down
41 changes: 41 additions & 0 deletions docs/12-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,47 @@ module.exports = {
};
```

## Different Page Height Variables for each source
```javascript
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, do this:

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

The same also applies to --page-width*

## Other recipes?

If you have other recipes then please share them.