Bug 496914 - PDF created by Skanpage cannot be processed by GhostScript "-dPDFSTOPONERROR"
Summary: PDF created by Skanpage cannot be processed by GhostScript "-dPDFSTOPONERROR"
Status: REPORTED
Alias: None
Product: Skanpage
Classification: Applications
Component: general (show other bugs)
Version: 24.08.3
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Alexander Stippich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-12-02 05:13 UTC by Matt P
Modified: 2024-12-02 05:13 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
problem PDF example created by skanpage (1.16 MB, application/pdf)
2024-12-02 05:13 UTC, Matt P
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt P 2024-12-02 05:13:57 UTC
Created attachment 176276 [details]
problem PDF example created by skanpage

SUMMARY
PDF created by Skanpage may be malformed, generates error with GhostScript "-dPDFSTOPONERROR" flag

Using paperless-ngx to import  a PDF created by skanpage.x86_64 24.08.3-1.fc41

from paperless error logs:
subprocess.CalledProcessError: Command '['gs', '-dQUIET', '-dSAFER', '-dBATCH', '-dNOPAUSE', '-dInterpolateControl=-1', '-sDEVICE=jpeggray', '-dFirstPage=1', '-dLastPage=1', '-r200.000000x200.000000', '-dPDFSTOPONERROR', '-o', '-', '-sstdout=%stderr', '-dAutoRotatePages=/None', '-f', '/tmp/ocrmypdf.io.bnzkaw75/origin.pdf']' returned non-zero exit status 1.

This is a known issue/behavior with some PDFs: 
https://docs.paperless-ngx.com/troubleshooting/#database-warns-about-unique-constraint-documents_tag_name_uniq
> https://github.com/ocrmypdf/OCRmyPDF/issues/1162
>> https://bugs.ghostscript.com/show_bug.cgi?id=707258
gs version 10.03.1

I can run the command manually:
gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -dInterpolateControl=-1 -sDEVICE=jpeggray -dFirstPage=1 -dLastPage=1 -r300.000000x300.000000 -dPDFSTOPONERROR -o - -sstdout=%stderr -dAutoRotatePages=/None  -f inputfile.pdf  > outfile.jpg

Where it will fail, and removing -dPDFSTOPONERROR and the command succeeds


STEPS TO REPRODUCE
1. Scan document with skanpage
    If any of this matters: (Epson ES-300W.  Scan source: ADF Duplex, scan mode:color, bit depth 8bit, scan resolution 300, top left x&y 0, bottom right x 215.8,  bottom right y 279.4, ADF skew correction (checked), Scan area size: Letter)
2. Save as PDF, or Export as PDF (same result with both)
3. use GS command to convert the pdf and observe failure: gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -dInterpolateControl=-1 -sDEVICE=jpeggray -dFirstPage=1 -dLastPage=1 -r300.000000x300.000000 -dPDFSTOPONERROR -o - -sstdout=%stderr -dAutoRotatePages=/None  -f inputfile.pdf  > outfile.jpg
4. Remove "-dPDFSTOPONERROR" flag and observe success

OBSERVED RESULT
Failed conversion of pdf created by skanpage

EXPECTED RESULT
successful conversion of pdf created by skanpage

SOFTWARE/OS VERSIONS
$ kinfo
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.8-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 4800H with Radeon Graphics
Memory: 15.0 GiB of RAM
Graphics Processor: AMD Radeon Graphics


ADDITIONAL INFORMATION
Attaching example bad document pdf
Failed with 2 page (2 sided) or single page document.  attaching smaller single side document that failed

Example output
$ gs -dQUIET -dSAFER -dBATCH -dNOPAUSE -dInterpolateControl=-1 -sDEVICE=jpeggray -dFirstPage=1 -dLastPage=1 -r300.000000x300.000000 -dPDFSTOPONERROR -o - -sstdout=%stderr -dAutoRotatePages=/None  -f test-saveAll-pdfDocument-1page.pdf  > TEST-outfile.jpg
Error: /typecheck in --runpdf--
Operand stack:   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Execution stack:   %interp_exit   .runexec2   --nostringval--   runpdf   --nostringval--   2   %stopped_push   --nostringval--   runpdf   runpdf   false   1   %stopped_push   1933   1   3   %oparray_pop   1932   1   3   %oparray_pop   1917   1   3   %oparray_pop   1918   1   3   %oparray_pop   runpdf   runpdf   runpdf   runpdf
Dictionary stack:   --dict:754/1123(ro)(G)--   --dict:0/20(G)--   --dict:86/200(L)--   --dict:6/10(L)--
Current allocation mode is local
GPL Ghostscript 10.03.1: Unrecoverable error, exit code 1
$