Bug 707258 - Ghostscript 10 reports spurious(?) outline error when rewriting PDF
Summary: Ghostscript 10 reports spurious(?) outline error when rewriting PDF
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 10.01.2
Hardware: All All
: P2 minor
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-12 08:38 UTC by James R Barlow
Modified: 2023-10-12 10:47 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
ecma PDF (2.20 MB, application/pdf)
2023-10-12 08:38 UTC, James R Barlow
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James R Barlow 2023-10-12 08:38:33 UTC
Created attachment 24954 [details]
ecma PDF

Using the attached PDF as input (downloaded from here).
https://www.ecma-international.org/wp-content/uploads/ECMA-395_1st_edition_december_2010.pdf

This file contains 65 outline entries, none of which have a destination associated, but all appear technically valid. Ghostscript 10 reports an error when processing this file. Ghostscript 9 reports no error, and other PDF error checking tools do not seem to identify any error.

Deleting the /Outlines tree will remove the error, so it appears related to outlines. 

(If -dPDFSTOPONERROR is dropped, Ghostscript 10 also proceeds, it is often desirable to leave this enabled....)


Ghostscript 10 output:

$ gs10 -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dSAFER -dESTACKPRINT -dPDFSTOPONERROR   -o _.pdf ecma.pdf

GPL Ghostscript 10.01.2 (2023-06-21)
Copyright (C) 2023 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Error: /typecheck in --runpdf--
Operand stack:
   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Execution stack:
    --%interp_exit--
    .runexec2
    -file-
    --runpdf--
    null
    2
    --%stopped_push--
    -file-
    --runpdf--
    --runpdf--
    false
    1
    --%stopped_push--
    1974
    1
    3
    --%oparray_pop--
    1973
    1
    3
    --%oparray_pop--
    1961
    1
    3
    --%oparray_pop--
    1962
    1
    3
    --%oparray_pop--
    --runpdf--
    --runpdf--
    --runpdf--
    --runpdf--
Dictionary stack:
   --dict:765/1123(ro)(G)--   --dict:0/20(G)--   --dict:76/200(L)--   --dict:18/20(L)--
Current allocation mode is local
GPL Ghostscript 10.01.2: Unrecoverable error, exit code 1
Comment 1 Ken Sharp 2023-10-12 10:47:18 UTC
(In reply to James R Barlow from comment #0)

> This file contains 65 outline entries, none of which have a destination
> associated

In fact, they do. The first entry in the Outline dictionary is object 3014:

13080 0 obj
<</First 13014 0 R/Count 66/Last 13014 0 R/Type/Outlines>>
endobj

13014 0 obj
<</First 13015 0 R/Parent 13080 0 R/Dest[null 0.0 0.0 1.0]/Count 65/Last 13079 0 R/Title(Ecma Standard 2nd page with registered logo 2010.pdf)>>
endobj

Notice the presence of a /Dest, that's a destination.

The syntax of destinations is defined on page 582 of the 1.7 PDF Reference. The array form should have contents which begin with a destination page, then a name object (/XYZ, /Fit, FitH, FitV, FitR, FitB, FitBH, FitBV) The remaining entries in the array depend on the name. Possible variations are 0, 1, 3 or 4 aditional values, depending.

The Dest here has a null page object, which makes no sense, and lacks a name to determine what kind of explicit destination it is. The remaining values 'look like' they are left, top and zoom, but a 'top' of 0 also makes no sense.



> but all appear technically valid.

Nope, the first Dest (and the only one in the Outline tree) is not valid. There are numerous Link annotations which do have valid Dest values, but those are not in the Outlines.


> Ghostscript 10 reports an
> error when processing this file. Ghostscript 9 reports no error

Which in this case demonstrates the improved error detection and reporting in the 10.x series, with the new PDF interpreter.


>, and other
> PDF error checking tools do not seem to identify any error.

Acrobat 9 Pro, Preflight, "Report PDF syntax issues" reports "Value at index N is not an indirect object". Drilling into that report to "General File Format Error" gets me 'The element at index 0 is of incorrect type' Value: null, Traversal Path: ->Outlines->Last->Dest'. It also complains about index 1 being of incorrect type with a value of 0.00. Note that the /Last entry in the Outlines dictionary also points to object 13014.

So Acrobat does tell you there's a problem, if you ask it.


So if you can explain to me, by referencing the PDF specification, why the Dest above is valid (even though Acrobat thinks it isn't) I'll be happy to look into it further. As far as I can see the Outline is invalid. Other tools may not bother to report the error.

The Outline looks borked anyway, apart from the first entry the fields make no sense.

 
> Deleting the /Outlines tree will remove the error, so it appears related to
> outlines. 

Yes, because the Outline is broken.

 
> (If -dPDFSTOPONERROR is dropped, Ghostscript 10 also proceeds, it is often
> desirable to leave this enabled....)

Yes, in order to detect errors, like this one.