![]() |
#1 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: May 2023
Device: none
|
epub to pdf - no page numbers on first pages
Hi, how can I add page numbers but remove them from the first pages? E.g. the first four pages are completely blank, and page numbers appear only after that.
I tried the approach described here: https://www.mobileread.com/forums/sh...+numbers+pages No luck. I get error messages as follows and no page numbers appear anywhere. KR file:///tmp/calibre_5.37.0_tmp_axl1d1r6/0br8yje__pdf_out/OEBPS/xyz-tli6-1-1.html:14:Uncaught SyntaxError: Unexpected token '<' |
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 62
Karma: 221034
Join Date: May 2021
Device: None
|
You haven't posted your code, so without that, it's difficult to provide an exact answer.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,260
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: May 2023
Device: none
|
I applied the following (and variants of it):
ebook-convert in.epub out.pdf --pdf-header-template '<header><div id="pagenum"></div><script>if (_PAGENUM_ > 5) document.getElementById("pagenum").innerHTML = "" + _PAGENUM_</script></header>' The if condition seems to cause the mentioned errors. The code given in the documentation works fine, e.g.: '<header><div></div><script>document.currentScript.parentNode.quer ySelector("div").innerHTML = "" + (_PAGENUM_ + 3)</script> </header' However, it only shifts page numbers. I want to remove them from the first pages. |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2022
Device: none
|
I'm sure you don't need this anymore, but if this is helpful to others in the future, I got this working.
I'm using Python for stuff, but hopefully you can see what I'm doing here and modify it for your purposes, minus the Python stuff. Should be straightforward to just create the command line option (i.e. you do not need Python for this): Code:
# Define footer templates with JavaScript to hide page number on page 1 # Note the use of single quotes for the outer HTML attributes and escaped double quotes for JavaScript strings if needed. centered_footer_script = "if (_PAGENUM_ === 1) { var el = document.getElementById('pn_center_id'); if (el) el.innerHTML = ''; }" centered_footer_html = f"<footer><div id='pn_center_id' style='margin: auto; font-size: smaller;'>_PAGENUM_</div><script>{centered_footer_script}</script></footer>" # The entire template string needs to be quoted for the command line. cmd_parts.append(f'--pdf-footer-template="{centered_footer_html}"') |
![]() |
![]() |
Advert | |
|
![]() |
Tags |
pdf and calibre |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Page numbers in Epub->PDF conversion | ghmerrill | Conversion | 13 | 12-03-2020 09:44 AM |
pdf (with page numbers) to epub | crill | Workshop | 13 | 01-12-2019 09:13 AM |
Removing page footers and numbers [PDF 2 EPUB] | Radium | Conversion | 7 | 06-15-2014 08:36 AM |
calibre EPUB->PDF: page numbers in printed TOC? | dancal | Conversion | 13 | 06-13-2013 08:32 PM |
how to hide page numbers from epub pages | Areej | Introduce Yourself | 2 | 06-24-2011 08:52 PM |