Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 05-02-2023, 02:04 PM   #1
berchas
Junior Member
berchas began at the beginning.
 
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 '<'
berchas is offline   Reply With Quote
Old 05-02-2023, 07:33 PM   #2
Foozle
Connoisseur
Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.Foozle ought to be getting tired of karma fortunes by now.
 
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.
Foozle is offline   Reply With Quote
Advert
Old 05-02-2023, 10:46 PM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,260
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://manual.calibre-ebook.com/con...verting-to-pdf
kovidgoyal is offline   Reply With Quote
Old 05-03-2023, 11:39 AM   #4
berchas
Junior Member
berchas began at the beginning.
 
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.
berchas is offline   Reply With Quote
Old 05-25-2025, 10:32 AM   #5
py_make_book
Junior Member
py_make_book began at the beginning.
 
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}"')
py_make_book is offline   Reply With Quote
Advert
Reply

Tags
pdf and calibre


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 04:56 AM.


MobileRead.com is a privately owned, operated and funded community.