Re: Finding # of pages in document?

Subject: Re: Finding # of pages in document?
From: Oisin McGuinness <oisin@xxxxxxxx>
Date: Tue, 15 Feb 2000 12:07:40 -0500
Nicholas Weininger said:
> The motivation here is that I'm trying to get
> a footer for RTF output that does "Page x of y" where y is the total
> number of pages in the document.
> 

A trick that has worked for me is that if you have someway to identify
an element which will almost certainly end up on the last page of a
document (not guaranteed for very long paragraphs), then do something like
this (excerpt from a quiz.dsl, which handles a quiz dtd, root element named
"quiz", elements "q" and "a"):

;; Define a mode for use in header 
(mode page-number
        (default (current-node-page-number-sosofo)))
;; Implementation from DSSSL digest #175. Compare standard page 136.
(define (node-list-last nl)
        (node-list-first (node-list-reverse nl)))

(element QUIZ
    (make simple-page-sequence
       left-header:
         (make sequence
               font-posture: 'italic
               (process-first-descendant "TITLE"))
       right-header:
         (make sequence
               font-posture: 'italic
               (sosofo-append
               (literal "Page ")
               (page-number-sosofo)
               (literal " of ")
               (with-mode page-number
                (process-node-list
                        (node-list-last
                        (select-elements
                                (descendants (current-node))
                                "Q"))))))
       input-whitespace-treatment: 'collapse
       quadding: 'justify
        (process-children-trim)))


This assumes the last Q element in the document is likely to be on the last page....


Oisin McGuinness

Sumitomo Bank Capital Markets
277 Park Avenue
New York NY 10172
USA

(212)-224-4913, email: oisin@xxxxxxxx


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread