• Bug#266166: gs-esp: pdf2dsc doesn't renumber pages according to PageLab

    From Jason McCarty@1:229/2 to All on Tue Aug 17 01:10:11 2004
    From: [email protected]

    Package: gs-esp
    Version: 7.07.1-9
    Severity: normal
    Tags: patch

    pdf2dsc doesn't attempt to renumber pages as specified by the PDF
    document's PageLabels entry. This causes the numbers on the left side of
    gv not to match the numbers rendered on the pages, for example. The
    following patch fixes that, by teaching pdf2dsc what to do with the
    PageLabels entry. I also removed the (redundant, backwards) concatstr
    function.

    The patch probably also applies to gs-gpl and gs-afpl. I'm not sure how
    I ought to submit this upstream though, since there are so many
    upstreams! What do you think?


    --- lib/pdf2dsc.ps.orig 2004-08-01 02:25:08.000000000 -0400
    +++ lib/pdf2dsc.ps 2004-08-16 18:04:50.000000000 -0400
    @@ -51,14 +51,6 @@
    /DSCstring 255 string def
    /MediaTypes 10 dict def

    -% (str1) (str2) concatstr (str1str2)
    -/concatstr {
    - 2 copy length exch length add string
    - dup dup 5 2 roll copy length
    -% stack: newstring newstring str2 str1-length
    - exch putinterval
    -} bind def
    -
    GS_PDF_ProcSet begin
    pdfdict begin
    PDFfile
    @@ -73,7 +65,7 @@
    3 -1 roll sub 3 1 roll exch sub exch
    2 array astore
    aload 3 1 roll 10 string cvs exch 10 string cvs
    - (x) exch concatstr concatstr cvn
    + (x) 3 -1 roll concatstrings concatstrings cvn
    MediaTypes 3 1 roll exch put
    } for

    @@ -122,10 +114,85 @@
    DSCfile PDFname write==only
    ( \(r\) file pdfopen begin\n) puts
    (%%EndSetup\n) puts
    +
    + /HasPageLabels false def % see "Page Labels" in the PDF Reference
    + Trailer /Root knownoget {
    + /PageLabels knownoget {
    + /Page