Same page number on front and back of card

43 Views Asked by At

I'm trying to create a stylesheet that will output a document as a series of 5x8 cards. They want the front and back of the card to have the same page number (so when you print it out, the first card is "Card A" and shows "Card A" on the front and back). But they don't want to have to author each card as its own element. I can't for the life of me figure out how to implement it without dealing with Area Trees or manually tagging individual cards.

Is there something I'm missing?

Edited to add:

Each "card" is the front and back of a 5x8 pageset so that when it's printed on card stock, you get the same card number. The source data would look something like:

<card>
   <header>[...]</header>
   <step>Do this</step>
   <step>Do that</step>
</card>
<card>
   <header>[...]</header>
   <step>Do this</step>
   <step>Do that</step>
   [...]
   <step>You've done enough steps that it's overflowed onto another card</step>
</card>

In that scenario, the first card element creates Card A and with only a couple steps, the back of Card A would be blank. The second card element would create Card B, which would have text on the front and back (and the back would still be labelled as Card B) and then the extra text would flow onto Card C.

I can't count the individual elements because the overflow may create more physical cards than there are card elements. And I can't use fo:page-sequence because it wants to number the back of the cards separately.

2

There are 2 best solutions below

2
Tony Graham On

Assuming that there's a series of some element that generates one card for each element, use xsl:number (XSLT 1.0: https://www.w3.org/TR/1999/REC-xslt-19991116#element-number) with format="A" to generate the A, etc. for each card based on the current element's position in the sequence.

0
Tony Graham On

You could do a variation on the trick usually used for parallel translations, e.g., at https://stackoverflow.com/a/52776328/4092205

  • Generate two documents with identical copies of your content
  • Use format="A" on your fo:page-sequence to get the A, etc.
  • In both, use your 5x8 page size, but define the fo:region-body as two columns that are each as wide as what the fo:region-body should be, and also use a wide column-gap
  • In the second document, set the margins on the fo:region-body such that the content of the second column appears on the page
  • Create the two PDFs
  • Use pdftk or similar to interleave the pages from the two PDFs. See: