View Single Post
Old 10-11-2024, 06:05 AM   #20
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,615
Karma: 7891011
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by kovidgoyal View Post
With that commit, the simplest I can make it is:

Code:
<header><canvas style="width: _WIDTH_PIXELS_px; height: _HEIGHT_PIXELS_px;" width="_WIDTH_PIXELS_" height="_HEIGHT_PIXELS_"><script>
canvas = document.currentScript.parentNode
s = window.getComputedStyle(canvas)
ctx = canvas.getContext("2d");
ctx.font = s.font
ctx.fillStyle = 'black';
ctx.fillText("section: _SECTION_", 5, 5 + canvas.height / 2);
upon a quick test I confirm it is working fine, here's the output:
header after new commit - Nineteen eighty-four - George Orwell.pdf

On current version I found these settings to look fine, with a white transparent background and grey text:

PHP Code:
<header>
  <
canvas>
  <
script>
    
canvas document.currentScript.parentNode;
    
canvas.height 120;
    
canvas.width 1400;
    
ctx canvas.getContext("2d");
    
ctx.font "12px sans-serif";
    
ctx.fillStyle 'transparent';
    
ctx.fillRect(00canvas.widthcanvas.height);  
    
ctx.fillStyle 'grey';
    
ctx.fillText("_TITLE_"2canvas.height 3);
    
ctx.fillText("_SECTION_"250canvas.height 3);
    
ctx.fillText("_AUTHOR_"500canvas.height 3); 
PHP Code:
<footer>
  <
canvas>
  <
script>
    
canvas document.currentScript.parentNode;
    
canvas.height 120;
    
canvas.width 1400;
    
ctx canvas.getContext("2d");
    
ctx.font "12px sans-serif";
    
ctx.fillStyle 'transparent';
    
ctx.fillRect(00canvas.widthcanvas.height);  
    
ctx.fillStyle 'grey';
    
ctx.fillText("_PAGENUM_/_TOTAL_PAGES_"260canvas.height 3); 
looks like this:
header and footer white bg grey text - Nineteen eighty-four - George Orwell.pdf

I've attached the trimmed EPUB I used if someone wants to do further testing
Attached Files
File Type: epub trimmed-Nineteen eighty-four - George Orwell.epub (61.3 KB, 118 views)

Last edited by Comfy.n; 10-11-2024 at 06:38 AM.
Comfy.n is offline   Reply With Quote