Bug 694277 - Improve pdfmark processing to handle unusual names in named destinations
Summary: Improve pdfmark processing to handle unusual names in named destinations
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.07
Hardware: PC Linux
: P4 enhancement
Assignee: Ken Sharp
QA Contact: Bug traffic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-29 08:49 UTC by KSK
Modified: 2013-07-31 01:21 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Encounter Error message while converting the PS to PDF (1.32 MB, application/postscript)
2013-05-29 08:50 UTC, KSK
Details

Note You need to log in before you can comment on or make changes to this bug.
Description KSK 2013-05-29 08:49:58 UTC
Hi am new to this Ghostscript.

When i tried with the Ghostscript 9.07 version i found some error message:

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dDOPDFMARKS=false -sOutputFile=Test.pdf Test.ps
GPL Ghostscript 9.07 (2013-02-14)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /rangecheck in /��aff1
Operand stack:
   --nostringval--   Dest   ��aff1   Rect   --nostringval--   Border   --nostringval--   LNK   --nostringval--   1   --nostringval--   1   false   --nostringval--   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1916   1   3   %oparray_pop   1915   1   3   %oparray_pop   1899   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1917   8   4   %oparray_pop   --nostringval--   2   1   5   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1169/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--   --dict:90/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 56617
GPL Ghostscript 9.07: Unrecoverable error, exit code 1
GPL Ghostscript 9.07: ERROR: A pdfmark destination page 112 points beyond the last page 1.

Could you please help me out to find out the solution.

Thanks & Regards,
KSK
Comment 1 KSK 2013-05-29 08:50:57 UTC
Created attachment 9913 [details]
Encounter Error message while converting the PS to PDF
Comment 2 Ken Sharp 2013-05-29 14:09:07 UTC
The file uses pdfmarks to create a variety of structures in the output PDF file. In particular it makes use of named destinations and Link annotations (it also uses the obselete /LNK method).

The names of the destinations use Unicode (UTF-16BE) strings, which are converted into PostScript names in order to use the pdfmark syntax.

Now, names in PDF cannot contain certain characters (unlike PostScript) and these include 0x00. So we cannot create a name in PDF which contains UTF-16. As a result we cannot create a simple annotation with a named destination which is actually a name object.

It is possible to work around this, by using a string to contain the name, and then creating a names table which maps strings to destinations, and this is what Acrobat does to solve this.

At present pdfwrite does not construct a names table for named destinations, so we cannot use this approach. This results in the error you see, because we are unable to process the pdfmark in the PostScript.
Comment 3 Ken Sharp 2013-05-29 16:26:07 UTC
This commit 2d04d5942b3e97b06a7ac4ed767a6c481d4421f4 resolves the problem, but note the caveats in the commit log.
Comment 4 KSK 2013-05-30 06:06:01 UTC
Thanks Ken. We looking forward for the patch this will be sort out my problem.

Thanks & Regards,
KSK
Comment 5 KSK 2013-05-31 10:35:31 UTC
Hi ken,

Thanks for fixing the bug. 

Am new to this GS. I dont know where to download those files and how to compile. Is there any guide to help me out?

Thanks,
KSK
Comment 6 Ken Sharp 2013-05-31 10:52:14 UTC
(In reply to comment #5)

> Am new to this GS. I dont know where to download those files and how to
> compile. Is there any guide to help me out?

The commit in comment 3 is a hyperlink, if you click it you will get to the commit page, which includes a diff of the changes (as well as the explanatory commit log). There you can get a diff of each changed file individually, a diff containing all the changes to the files in one go, or a 'snapshot' which is a download of the entire Ghostscript source at that point (if you don't feel you can apply a diff).

Since you are on Linux you should be able to use the 'patch' utility to apply the diff to the released source.

You then have to build Ghostscript, you will find instructions in the Ghostscript directory; /ghostpdl/gs/doc/make.htm
Comment 7 KSK 2013-05-31 13:07:12 UTC
Ken,

Once again Thankyou. 

Its workfing fine. Also am very much happy to use this Ghostscript and for your swift response.

Thanks & Regards,
KSK
Comment 8 KSK 2013-07-29 04:11:31 UTC
When trying the below command I received the following Error Message :  UseCIEColor for UseDeviceIndependentColor

Ghostscript Version : GPL Ghostscript GIT PRERELEASE 9.08 
Command : gs -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dBATCH -sOutputFile=out.pdf input.ps

GPL Ghostscript GIT PRERELEASE 9.08 (2013-01-29)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GPL Ghostscript GIT PRERELEASE 9.08: Set UseCIEColor for UseDeviceIndependentColor to work properly.
Unrecoverable error: stackunderflow in .setdistillerparams


Kindly advise me how to handle this.
Comment 9 Ken Sharp 2013-07-31 01:21:16 UTC
(In reply to comment #8)
> When trying the below command I received the following Error Message : 
> UseCIEColor for UseDeviceIndependentColor

Please don't add to closed bugs!

> This software comes with NO WARRANTY: see the file PUBLIC for details.
> GPL Ghostscript GIT PRERELEASE 9.08: Set UseCIEColor for
> UseDeviceIndependentColor to work properly.
> Unrecoverable error: stackunderflow in .setdistillerparams
> 
> 
> Kindly advise me how to handle this.

The message says it all 'Set UseCIEColor for UseDeviceIndependentColor to work properly'.