Closed Nivalux closed 3 months ago
I am having the same problem.
Browser: Chrome Direct installation on debian 11 proxmox CT
scanserjs version: 3.0.3
Printer/Scanner: Epson WF-3620 via WSD (somehow web UI shows the scanner two times, but only one accepts the ADF duplex scan option).
In the printer setting (on the device display) its possible to set an flip orientation (left side or top) for all scan targets except of WDS, so it changes nothing. It seems that the ADF does a top flip. Pages is flipped in the tray, after scanning.
Just FYI. I could bypass this problem with paperless-ngx. During my research how to integrate ocrmypdf into scanservjs I figured out that its already included in paperless-ngx and that just the --rotate-page-threshold needed to be reduces to actually rotate my scans. just check the config parameter PAPERLESS_OCR_ROTATE_PAGES_THRESHOLD.
Thank you for the tip, I'll try it out! I looked more in the direction of "how to rotate every second page" while I was searching, but this works too 👍
omg, thats a very good idea and so obvious... because the ocr-rotate does not work if there is no text on the page, so this approach is not solid to all cases, which I really hate.
Did you come up with any results or intermediate progress? I would like to implement a static rotate of each even-numbered page instead of relying on the ocr-guessing...
I just found this: https://github.com/qpdf/qpdf
qpdf in.pdf out.pdf --rotate=+180:1-z:even
now we need to create a pipeline in scanservjs with this.
We probably need what is described here, to integrate it: https://github.com/sbs20/scanservjs/blob/master/docs/12-recipes.md#add-actions-and-call-after-a-specific-pipeline
The pipeline action in the commands array is executed per page, if I see that correctly. But we want to act on the finished pdf. So the afterAction is probably what we want, but not sure if that is the combined pdf or still single pages. Guess we will have to try.
Or maybe we can use the afterScan function: https://github.com/sbs20/scanservjs/blob/master/docs/10-configuration.md#afterscanfileinfo
A pipeline can work on per page basis, but if you have a look on the ocrmypdf recipe form the docs:
config.pipelines.push({
extension: 'pdf',
description: 'ocrmypdf (JPG | @:pipeline.high-quality)',
get commands() {
return [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- pdf:-',
`ocrmypdf -l ${config.ocrLanguage} --deskew --rotate-pages - scan_0000.pdf`,
'ls scan_*.*'
];
}
});
you see that the command 'convert @- pdf:-'
already converts the separate jpgs to a single multi pages PDF. As confirmation you can check the docs from ocrmypdf. It uses a single PDF as input.
Finally I would prefer a device related pipeline that calls qpdf in.pdf out.pdf --rotate=+180:1-z:even
So, in the ocrmypdf pipeline I think you just have to replace the command and 'in.pdf' must be replaced by '-' (which is the pointer for stdin, according to explanation in app-server/config/config.default.js
config.pipelines.push({
extension: 'pdf',
description: 'Rotate every even page (PDF | @:pipeline.high-quality)',
get commands() {
return [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- pdf:-',
`qpdf - scan_0000.pdf --rotate=+180:1-z:even`,
'ls scan_*.*'
];
}
});
Could you try that out? I am not at home and I am currently working on other topics, so I can't tell when I am able to do it :)
I did it. I couldn't hold my self back.
Install the qpdf package
eg. apt-get install qpdf
The above posted pipeline doesn't work, here is the fix. qpdf can't handle the stdin, so it must be saved as PDF file first.
add following pipeline:
config.pipelines.push({
extension: 'pdf',
description: 'Rotate every 2nd page ( PDF | @:pipeline.high-quality)',
get commands() {
return [
'convert @- -quality 92 tmp-%04d.jpg && ls tmp-*.jpg',
'convert @- scan_0000.pdf',
`qpdf scan_0000.pdf --replace-input --rotate=+180:1-z:even`,
'ls scan_*.*'
];
}
With this you get every 2nd page rotated.
I corrected "odd" to "even" in previous comments as well, to not confuse anybody in the future.
Thank you :) I would have had a look at it at the weekend. Now I will try integrating your solution in the docker image. When scanning with duplex, it always scans both sides and keeps them, even if they are white, right? Then this solution should work perfectly fine 👍
I just did a quick test with my test page, which has text on both sides, but yes. The command can't do anything else than just rotate every second page, doesn't matter what's on it.
When you confirm that this works for you, let's suggest to add this to the recipes documentation.
Just tested it and it works perfectly, thank you :) I use the docker version, so I used this Dockerfile and added it into my docker-compose.yml as a "build: ."
FROM sbs20/scanservjs:v3.0.3 AS scanservjs-base
RUN apt-get update \
&& apt-get install -yq \
qpdf \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*;
Describe the bug When scanning pages in ADF duplex mode, then the backsite get's scanned, but it is upside down. It needs to be rotated 180°.
To Reproduce Steps to reproduce the behavior:
Expected behavior Either the backside having the correct orientation or having an option, to always rotate backside pages
Client (please complete the following information):
Server (please complete the following information):