Bug 687901 - "wrong operand type" error
Summary: "wrong operand type" error
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: master
Hardware: PC Windows 2000
: P3 normal
Assignee: Igor Melichev
URL:
Keywords:
: 688242 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-20 08:17 UTC by Edward
Modified: 2008-12-19 08:31 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
PostScript file (zipped with winzip) (191.06 KB, application/octet-stream)
2005-01-20 08:18 UTC, Edward
Details
PDF file created with gs 8.34 (65.35 KB, application/pdf)
2005-01-20 08:19 UTC, Edward
Details
cur-.pdf (970 bytes, application/pdf)
2005-08-23 03:43 UTC, Igor Melichev
Details
cur.pdf (970 bytes, application/pdf)
2005-08-23 03:44 UTC, Igor Melichev
Details
t1.ps (130 bytes, application/postscript)
2005-08-23 04:03 UTC, Igor Melichev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Edward 2005-01-20 08:17:47 UTC
When trying to convert the attached PostScript document into PDF with GS Head 
(i also tried it with gs 8.34 / 8.14 - same error) i get a PDF document that 
displays "Wrong operand type" error when i'm trying to open it in Acrobat 
Reader.

Adobe Distiller converts this document into a fine PDF.
Comment 1 Edward 2005-01-20 08:18:37 UTC
Created attachment 1167 [details]
PostScript file (zipped with winzip)
Comment 2 Edward 2005-01-20 08:19:30 UTC
Created attachment 1168 [details]
PDF file created with gs 8.34
Comment 3 Jack Moffitt 2005-01-26 08:17:40 UTC
Confirmed in CVS HEAD and GS 8.50
Comment 4 Alex Cherepanov 2005-06-22 20:03:30 UTC
The PDF file contains the following:

q 
0 2 0 0 0 0 cm
-92559631349317831000000000000000000000000000000000000000000000.0
-92559631349317831000000000000000000000000000000000000000000000.0 m
-92559631349317831000000000000000000000000000000000000000000000.0
-92559631349317831000000000000000000000000000000000000000000000.0 l
S
Q
Comment 5 Alex Cherepanov 2005-08-06 09:05:36 UTC
*** Bug 688242 has been marked as a duplicate of this bug. ***
Comment 6 Igor Melichev 2005-08-23 01:04:51 UTC
1. I do not see "00000000000000000000000000000000000000000" in the attached 
PDF - neither in the original file, nor in an unpacked copy made with pdfinflt. 
Not clear what document Alex used.

2. Acrobat Reader 4 opens the attached document with no error.

3. Acrobat Reader 5 and and Adobe reader 6 opens the attached document with 
the "Wrong operand tipe" message.

4. The problem (3) is reproducible with the current HEAD.
Comment 7 Igor Melichev 2005-08-23 01:12:01 UTC
After I replaced all occurances of "0 2 0 0 0 0 cm" with "0 2 2 0 0 0 cm", the 
file opens with no error with Adobe Reader 6 and Acrobat Reader 5.
Comment 8 Igor Melichev 2005-08-23 02:29:07 UTC
Well, I know where Alex took huge numbers.
The function gdev_vector_dopath_segment calls gs_point_transform_inverse 
without checking the return code, but with sample document it returns the 
undefinedresult error code, and leaves the result point argument uninitialized. 
With my build it happens to be zero, but Alex uses a different compiler.
Comment 9 Igor Melichev 2005-08-23 02:44:59 UTC
The reason of the problem is that the sample document first constricts a path, 
and then sets a generate CTM and strokes with the degenerate CTM. The function 
gdev_vector_dopath_segment doesn't priopagate the error code and leaves an 
uninitialised variable, therefore Alex's hguge number may appear 
indeterministically. gdev_vector_dopath applies the inverse matrix to provide a 
right stroking if the CTM is set BEFORE constructing the path.

However a mathematically corect result isn't possible when CTM doean't change 
after the path is constructed. Need to know whether PDF allows to change it 
between constructing a path and stroking. If so, the logic of 
gdev_pdf_stroke_path to be changed dramatically.
Comment 10 Igor Melichev 2005-08-23 03:16:47 UTC
Some quotes from PDF 1.4 page 152 : "The effect produced in device space
depends on the current transformation matrix (CTM)in effect at the time the
path is stroked.If the CTM speci fies scaling by different factors in the 
horizontal and vertical dimensions,the thickness of stroked lines in device 
space will vary according to their orientation."
Page 163 : "Table 4.9 shows the path construction operators.All operands are 
numbers de-noting coordinates in user space."
Page 162 : "In PDF (unlike PostScript),the current path is not part of the 
graphics state and is not saved and restored along with the other graphics 
state parameters."

However we're unclear what coordinate system does the PDF viewer must use for 
storing the clipping path : the device space or the user space ? What is the 
defined result if CTM changes between path construction and stroking ?
Comment 11 Igor Melichev 2005-08-23 03:43:25 UTC
Created attachment 1645 [details]
cur-.pdf

A mannualy made PDF with changing the CTM between path construction and
stroking.
Comment 12 Igor Melichev 2005-08-23 03:44:55 UTC
Created attachment 1646 [details]
cur.pdf

A PDF file with setting the CTM before path construction, generated with
current HEAD.
Comment 13 Igor Melichev 2005-08-23 03:48:36 UTC
Acrobat Reader 4, Acrobat Reader 5, Adobe Reader 6 all render same page with 
cur-.pdf and cur.pdf ! Thus I conclude that Adobe stores the path in the user 
space coordinates, and applies the CTM in the time of stroking. Contrary 
Ghostscript applies one CTM in the time of path construction, and another CTM 
in the time of stroking.
Comment 14 Igor Melichev 2005-08-23 04:00:58 UTC
Thus, the paragraph2 of Comment#9 and Comment #13 imply that the sample 
document is mathematically impossible to convert precisely into PDF.
Comment 15 Igor Melichev 2005-08-23 04:03:05 UTC
Created attachment 1647 [details]
t1.ps

A Postscript file for testing what Adobe does with anisotropic line width. Both
CPSI and Distiller+Reader paint an constant width line with this test.
Ghostscript with a raster device renders a zero width line, which looks
incompatible to Adobe.
Comment 16 Igor Melichev 2005-08-23 04:16:54 UTC
Well, after some experimenting with Distiller+Reader, we think that :

1. Distiller stores the path is device space coordinates, as a regular 
Postscript interpreter.

2. If the stroking happens with an anisotropic CTM, the anisotropic width 
appear with Distiller+Reader, except the CTM is degenerate. The distiller 
writes an anisotropic matrix and then inverse-transforms the path with it.
It appears same as Ghostscript does.

3. If the stroking happens with an anisotropic degenerate CTM, Distiller+Reader 
paints a constant line, and uses the non-zero matrix coefficient to compute the 
line width. Ghostscript must do same, but currently gives an undeterministic 
behavior and the "Wrong operand type" error.