mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.07k stars 23 forks source link

Footer changes PDF export accuracy #70

Closed Nicceboy closed 7 months ago

Nicceboy commented 7 months ago

Continuing from the original PDF export issue..

Seems like I figured out the main reason. I had different footer than in the demo, and that caused "drifting away". I had page numbering on right side.

Maybe this is endless cat and mice competition, since there can be quite many variations for the footers?

By using progress footer, the accuracy is much better for exporting. Other issues are solved by making terminal larger.

mfontanini commented 7 months ago

Hmm weird, even with a custom footer this still works perfect for me. Is there anything crazy about your footer? Are you using emojis? If you could upload a minimal .md presentation that reproduces the issues that'd be great.

Nicceboy commented 7 months ago

Here is one:

---
theme:

  path: theme.yaml

title: Lorem ipsum dolor sit amet
author: Lorem Ipsum 28.11.2023
---

About lorem
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

# Lorem Ipsum 

* sunt in culpa qui officia deserunt mollit anim id est laborum.

# Ipsum Amet

<!-- end_slide -->

Dolore Magna?
---

<!-- column_layout: [2, 1] -->
<!-- column: 0 -->

* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<!-- column: 1 -->

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt. 
<!-- end_slide -->
Lorem ipsum?
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Theme:

default:
  margin:
    percent: 5
  colors:
    foreground: "e6e6e6"
    background: "0D1116"

intro_slide:
  title:
    alignment: center
    colors:
      foreground: "b4ccff"
  subtitle:
    alignment: center
    colors:
      foreground: "a5d7e8"
  author:
    alignment: center
    colors:
      foreground: "b6eada"
    positioning: page_bottom

footer:
 style: template
 right: "{current_slide} / {total_slides}"
mfontanini commented 7 months ago

Does the issue happen on both Mac and Linux?

Nicceboy commented 7 months ago

Does the issue happen on both Mac and Linux?

Happens on both.

mfontanini commented 7 months ago

I can't reproduce again :(. Could you upload the resulting PDF and do the .final.html dance you did on the other issue? I'm a bit surprised actually, in its current form this is using specific pixel heights for everything so it shouldn't be platform dependent anymore. I did initially have issues but I got rid of the source of them a while back it seems.

Nicceboy commented 7 months ago

Here are the files:

bug.pdf

(tmux 3.3a, wezterm 20230712-072601-f4abf8fd, MacOS 14.1.1, no sixel feature)

Click me for HTML ```html

Lorem ipsum dolor sit amet
Lorem Ipsum 28.11.2023
1 / 4

About lorem
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Lorem Ipsum
sunt in culpa qui officia deserunt mollit anim id est laborum.
Ipsum Amet
2 / 4

Dolore Magna?
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor Lorem ipsum dolor sit amet, consectetur
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis adipiscing elit, sed do eiusmod tempor
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. incididunt.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
3 / 4

Lorem ipsum?
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
4 / 4
```
mfontanini commented 7 months ago

Nice, I can reproduce now. This is again tmux 3.3a, I need to dig in.

mfontanini commented 7 months ago

Okay, presenterm-export 0.1.7 fixes this. This is AFAICT an issue in tmux: it claims the session has a height of N but the captured panes have a size of N-1 so that's why you see text moving up one line per slide. Can you update and double check?

Nicceboy commented 7 months ago

Seems to work for my original slides! 🎉

Nicceboy commented 7 months ago

As a side node, would you accept contribution to convert the exporter to Rust if I have time some day? There might be tooling for that.

Personally I really like this tool, and will likely use it in the future as well. Python dependency is just something I would love to drop.

mfontanini commented 7 months ago

Awesome! Regarding the exporter tool, for sure. I think the main problem is the conversion from HTML to PDF. That's non trivial and I don't know if there's something in Rust that does the job right. But if there is, I'm all for migrating it.

Nicceboy commented 7 months ago

Yeah, there are no many native libraries for HTML-> PDF conversion I think. Most use headless browser to create the PDF.

There is this new Rust-based typesetting system: https://github.com/typst/typst Maybe that would be worth of exploration, if somekind of bridge can be built.

mfontanini commented 7 months ago

I'm not sure if this would be worth it tbh. It would be nice if the exporter was in rust too but it currently works fine (besides these last issues with tmux) and the resulting PDFs look exactly the same as the terminal presentation which IMO is a must. Redoing all the work in an entirely different approach just for the sake of avoiding python may not be worth it. If you do find a way to do this I'm open to contributions but it will probably be a good amount of work.

Nicceboy commented 7 months ago

Yeah, it will probably take a lot of time, which might not be necassary. It works well now.