Bug 695468 - /rangecheck in .installpagedevice error when combining LockDistillerParams, setpagedevice, and restore
Summary: /rangecheck in .installpagedevice error when combining LockDistillerParams, s...
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.14
Hardware: PC Windows 7
: P4 minor
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-03 22:21 UTC by Nick Phillips
Modified: 2014-09-05 07:04 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Very minimal test case (76 bytes, application/postscript)
2014-09-03 22:21 UTC, Nick Phillips
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Phillips 2014-09-03 22:21:36 UTC
Created attachment 11153 [details]
Very minimal test case

When LockDistillerParams is true, and we call setpagedevice within a save/restore block, the restore fails as below:

Error: /rangecheck in .installpagedevice

Based on the Adobe docs it sounds like LockDistillerParams should not cause any failure it should just cause requested changes to be ignored. Also I'm not sure whether it should interact with setpagedevice like this.

This is tested with version 9.14 on Windows 7 32-bit as below.

gswin32c.exe -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=test.pdf -c "<< /LockDistillerParams true >> setdistillerparams" -f test.ps

The attached file is as minimal as I can get. Our real world usage is to provide 2 input files (the saved Adobe Distiller options, and the PS file produced from a document composition tool). If the restore or setpagedevice lines are removed it works, and regardless it does produce a working file but we prefer not to just ignore error messages in our automated processing environment.
Comment 1 Ken Sharp 2014-09-04 02:08:20 UTC
The problem is the insane setpagedevice implementation.

When we restore back to the state prior to the setpagedevice (page device configuration is affected by gsave/grestore), we set the page device by using .installpagedevice which insists that all the keys must be processed (unlike normal setpagedevice).

Now we store the distiller params in the page device structure, so they too (properly) follow gsave and grestore. The problem is that if LockDistillerParams is set, pdfwrite doesn't bother to process the distiller params. This leaves the keys unprocessed and so .installpagedevice throws an error.

The only solution is to have pdfwrite process the keys even when its going to simply throw them away. This will impact performance slightly (but only when LockDistillerParams is true as otherwise we would always process these keys anyway) and means revising a lot of code.

Since it doesn't stop anything working, making it minor.
Comment 2 Nick Phillips 2014-09-04 21:32:52 UTC
Thanks for the explanation Ken.

I think in our situation disabling LockDistillerParams should be a safe and convenient workaround for now. I don't think print files should really be messing with the settings much anyway.
Comment 3 Ken Sharp 2014-09-05 07:04:05 UTC
I believe that commit 201ff60b950912c09d22b3b4ed0b57ed75c3587a should resolve this.