Created
December 5, 2016 13:20
-
-
Save hallvors/9d03be4d87aac50590ac32a94d91785f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html> | |
<head><title>Exclude some pages from numbering</title> | |
<link rel="help" href="http://www.princexml.com/forum/topic/3492/is-it-possible-to-skip-numbering-a-named-page-group"> | |
<script type="text/javascript"> | |
(function(){ | |
// This list can be customized by hand or auto-generated | |
var pages = {"3":1,"4":2,"5":3,"6":4,"8":5,"9":6} | |
// If you wish to auto-generate the list, add | |
// CSS selectors matching elements that should | |
// "suppress" page numbers here and run Prince once, | |
// then paste the output above: | |
var suppressPageNumForSelectors = ['div.notes']; | |
var numNotePagesSofar = 0; | |
Prince.addScriptFunc("pageNumOrNot", function(num) { | |
if(num in pages){ | |
numNotePagesSofar = pages[num]; | |
return 'Notes p ' + numNotePagesSofar; | |
} | |
num = parseInt(num, 10); | |
return '' + (num - numNotePagesSofar); | |
}); | |
// Below is code for auto-generating the list of pages that page numbers | |
// should be omitted for | |
Prince.trackBoxes = true; | |
Prince.addEventListener("complete", function() { | |
var pages = {}; | |
var numSeenNotePages = 0; | |
var lastSeenNotePage = null; | |
for(var i = 0; i < suppressPageNumForSelectors.length; i++) { | |
var elms = document.querySelectorAll(suppressPageNumForSelectors[i]); | |
for(var j = 0; j < elms.length; j++) { | |
var boxes = elms[j].getPrinceBoxes(); | |
for (var k = 0; k < boxes.length; ++k) { | |
if(boxes[k].pageNum !== lastSeenNotePage) { | |
numSeenNotePages++; | |
lastSeenNotePage = pages[boxes[k].pageNum]; | |
} | |
pages[boxes[k].pageNum] = numSeenNotePages; | |
} | |
} | |
} | |
console.log('// Paste this code into the script to suppress listed page numbers:'); | |
console.log('var pages = ' + JSON.stringify(pages)); | |
}); | |
})(); | |
</script> | |
<style> | |
@page small{ | |
size: a5 portrait; | |
} | |
@page { | |
@top-right { | |
content: prince-script(pageNumOrNot, counter(page)); | |
} | |
} | |
@page notespage{ | |
size: a5 portrait; | |
@top-right{ | |
content: prince-script(pageNumOrNot, counter(page)); | |
font-style: italic; | |
} | |
} | |
.page{ | |
page: small; | |
page-break-after: always; | |
} | |
.notes{ | |
page: notespage; | |
} | |
span::before{content: prince-script(pageNumOrNot, counter(page));} | |
</style> | |
</head> | |
<body> | |
<section> | |
<div class="page workbook"> | |
<p>This is filler text p <span></span></p> | |
</div> | |
<div class="page workbook"> | |
<p>This is filler text p <span></span></p> | |
</div> | |
<div class="page notes"> | |
<p><span></span></p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
</div> | |
<div class="page workbook"> | |
<p>This is filler text p <span></span></p> | |
</div> | |
<div class="page notes"> | |
<p><span></span></p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
<p>This is note page filler text</p> | |
</div> | |
<div class="page workbook"> | |
<p>This is filler text p <span></span></p> | |
</div> | |
<div class="page workbook"> | |
<p>This is filler text p <span></span></p> | |
</div> | |
</section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment