[gs-bugs] [Bug 691889] pdfwrite with "/PAGELABEL pdfmark" operator does not work with multiple pages

bugzilla-daemon at ghostscript.com bugzilla-daemon at ghostscript.com
Sat Jan 15 09:12:42 UTC 2011


SaGS <sags5495 at hotmail.com> changed:

           What    |Removed                     |Added
                 CC|                            |sags5495 at hotmail.com

--- Comment #2 from SaGS <sags5495 at hotmail.com> 2011-01-15 09:12:38 UTC ---
The /PAGELABEL pdfmark does not have any /Page key, so one can set the 
label for the ‘current’ page only (and, as a consequence, only for one 
page at a time). Since you call it at the very beginning, it’s expected 
to set a label for the 1st page and only for it.

Multiple /PAGELABELs for the same page: the pdfmark reference says the 
last one takes effect, so the result of your 1st commandline is OK. 
Note the /Page key is ignored.

Multiple /Label keys in a single /PAGELABEL pdfmark: there’s nothing in 
the pdfmark reference to allow this. So your 2nd commandline example is 
incorrect. The result could be an explicit PostScript error, but in 
general pdfmarks are forgiving. In this case, the implementation assigns 
a page label, one of those you specified, but there’s no rule as to 
which one to choose.

About page labels being 1..50 in the ‘old’ PDF: In short, they aren’t.
My Adobe Reader (on Windows) displays page numbers as ‘<pageindex> of 
<totalpages>’ (where <pageindex> is the page’s 1-based index in the file) 
if there are no page labels in the PDF, and ‘<label> (<pageindex> of 
<totalpages>)’ if there are. Note the use of ‘()’. I get ’2 of 50’ with 
the old PDF, and ‘(2 of 50)’ with the new one. The PDF format 
does not provide any way to define labels for some pages and let the 
labels for the others ‘absolutely undefined’. Those ‘other’ labels 
must be set to something, ‘empty’ being the closest thing to ‘undefined’.

How to set page labels from PostScript? I can think of 2 methods:

(A) The 100% documented way:

    Issue a /PAGELABEL as part of each page.

(B) The less documented way:

    Use low-level pdfmarks (/OBJ & co) to construct the /PabeLabels 
    number tree and connect it to the document’s {Catalog}. The advantage 
    is that you can define all page labels at once, and you can specify 
    how to automatically generate these labels. For example you can 
    request to ‘number pages 1..2 with the string "Page " followed by 
    roman numerals starting at "x"’ instead of ‘label 1st page with the 
    string "Page x", 2nd page with the string "Page xi"’.

    gswin32c -sDEVICE=pdfwrite -sOutputFile=50pages.pdf -dNOPAUSE

    GS>[/_objdef {pl} /type /dict /OBJ pdfmark
    GS>[{pl} <</Nums [0 <</P (Page ) /S /r /St 10>> 2 <<>>]>> /PUT pdfmark
    GS>[{Catalog} <</PageLabels {pl}>> /PUT pdfmark
    GS>50 { showpage } repeat

Configure bugmail: http://bugs.ghostscript.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the gs-bugs mailing list