Bug 691347

Summary: Error: /rangecheck in --.execform1--
Product: Ghostscript Reporter: Jordan <jordan.yelloz>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 8.71   
Hardware: All   
OS: All   
Customer: Word Size: ---
Attachments: An Illustrator CS5 PDF compatible AI file with a hidden layer and transparent cyan rectangle.
Ghostscript's distillation of the input file.
iText's wrapping of the distilled PDF.
This is the Java code that wraps the distilled PDF.

Description Jordan 2010-05-28 20:30:37 UTC
I am using a combination of Ghostscript and iText to do some basic PDF manipulations.

My process is the following:

1. The input PDF (can be any variety of PDF) goes into Ghostscript for distillation to remove hidden layers and PDF 1.5+ features.  Here's the command I'm using for this testcase:
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile='cyan-20-box.ai.distilled.pdf' -c '.setpdfwrite' -f 'cyan-20-box.ai'

2. Import the Ghostscript-distilled PDF with iText and write a new PDF from that page.  See the included Java code (it's pretty short and nothing special is being done).

3. Render the iText-generated PDF with Ghostscript.
gs -sDEVICE=nullpage -f cyan-20-box.ai.distilled.pdf.itext.1275078045895.pdf

This works okay most of the time but newer Illustrator PDF-compatible files with transparency seem to be problematic.  At step 3, Ghostscript fails with the following error:

GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Error: /rangecheck in --.execform1--
Operand stack:
   --dict:6/15(L)--   1   10   3   13
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   114   --nostringval--   1826   4   11   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   4   11   %oparray_pop   --nostringval--   (gstatetype)   --dict:0/0(L)--   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   581   --nostringval--   1826   6   14   %oparray_pop   --nostringval--   false   1   %stopped_push   1825   6   14   %oparray_pop   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1151/1684(ro)(G)--   --dict:1/20(G)--   --dict:75/200(L)--   --dict:75/200(L)--   --dict:108/127(ro)(G)--   --dict:288/300(ro)(G)--   --dict:22/25(L)--   --dict:6/8(L)--   --dict:21/40(L)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--   --dict:4/5(L)--   --dict:1/1(ro)(G)--   --dict:4/5(L)--   --dict:1/1(ro)(G)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1


I've checked the iText-generated file that goes into Ghostscript with Acrobat Pro 9.3 Preflight and it validates fine and prints fine so I think this is a Ghostscript issue.
Ghostscript has no problems rendering the initial Ghostscript-distilled file (cyan-20-box.ai.distilled.pdf).
Comment 1 Jordan 2010-05-28 20:32:41 UTC
Created attachment 6332 [details]
An Illustrator CS5 PDF compatible AI file with a hidden layer and transparent cyan rectangle.
Comment 2 Jordan 2010-05-28 20:33:16 UTC
Created attachment 6333 [details]
Ghostscript's distillation of the input file.
Comment 3 Jordan 2010-05-28 20:34:08 UTC
Created attachment 6334 [details]
iText's wrapping of the distilled PDF.
Comment 4 Jordan 2010-05-28 20:36:51 UTC
Created attachment 6335 [details]
This is the Java code that wraps the distilled PDF.

This is built with iText 2.1.7.  It should work fine with iText 5, just change com.lowagie. to com.itextpdf.
Comment 5 Alex Cherepanov 2010-05-29 04:39:49 UTC
The PDF file is incorrect. PDF specifies that the form XObject uses
the stream Resource dictionary and the page Resource dictionary. The latter may
be inherited from the page tree.

The sample file expects that the resource is inherited from an external
XObject stream.

Unfortunately, Adobe Acrobat does just this and Ghostscript will follow
the implementation rather then the spec.
Comment 6 Alex Cherepanov 2013-01-10 14:50:44 UTC
Search for misplaced resources has been recently added to Ghostscript.
See the bug 693490 for details.