Skip to content

Conversation

@rcoreilly
Copy link
Member

converting code from tdewolff canvas PDF rendering to support direct rendering to PDF files.

@rcoreilly rcoreilly marked this pull request as draft October 2, 2025 10:05
…rd system and text transforms etc, but should be good now.
…er / rich.Settings: it wasn't using the args passed in shaper anyway, and it is just cleaner to have one definitive location for global rich text settings (font names etc), so cleaned that up.
…roperties control pagination. just needs testing of that and floats
…ive transform -- pdf and svg renderers actually need the incremental one, not Cumulative! fixes pdf rendering of svgs (modulo missing features).
…thors to just a string so you can do random formatting on it.
…ays, using to center figures, prevent page breaks on headers, etc.
Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments through content.

// Authors are the optional authors of the page.
Authors []string
// Authors are the optional author(s) of the page.
Authors string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a string not a slice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it is awkward and unnecessary to have to parse and format. Just put everything as it should be in a string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but there also may be some contexts where it is useful to have each author separately. For example, if in content we want to have automatically generated author pages where you can see everything that someone has written, you need each author separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated thoughts on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just think it is too complex to deal with the formatting issues for academic-level author strings, where for example you need to be able to put affiliation symbols and other such things. When we implement search functionality, it would be easy to search within author string for name(s) etc. If we end up needing separate author strings later, it is easier to add those and then have them format into the current Authors string, which is the definitive record, so let's just put that on the stack and deal with it if/when it becomes necessary, OK?

})
})
tree.Add(p, func(w *core.Button) {
w.SetText("PDF").SetIcon(icons.PictureAsPdf).SetTooltip("PDF generates and opens / downloads the current page as a printable PDF file. See the Settings/Printer panel (Command+,) for settings.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placing this in the main toolbar by default is rather aggressive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? this is essential functionality, that works in all cases!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially having it at the start of the toolbar takes attention away from other buttons that are presumably more important for most people. I would rather have a general scene context menu button for PDF that you can use in any context (not just content), which would be quite useful.

Or if it is specific to content, still put it in a context menu, or at least not at the start of the toolbar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to add a default item at the end of the toolbar. we can add it to the overflow, but not to the end. it is very small. I suggest you let this one go for now and file an issue if you really want.

Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments through gpu.

Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments through math32.

Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments up to paginate.


func init() {
paint.NewSVGRenderer = svgrender.New
paint.NewPDFRenderer = pdfrender.New
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the impact of always importing the pdf renderer on binary size? Should this be more optional?

If it is included in every app, then we might as well put export to pdf in the default scene context menu.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it IS already in the core namespace, via the Grab snapshot keybinding (Control+Shift+G) -- try it! drops SVG, PDF, and PNG versions! Key point: you need a keyboard shortcut, not a menu, because otherwise the menu shows up in the snapshot!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably we could have a menu button that uses Defer or something like that to wait until the menu is closed before grabbing a snapshot. It's hard for an end user to know about Control+Shift+G, and it is also a nonstandard shortcut as far as I know. What about a print button with shortcut Cmd+P?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about another issue? sounds like it could be a bit complex and finding shortcuts is nontrivial, although the docs/keymaps page does suggest that Control+Shift+P is not taken. forget about Control+P however: that is core emacs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to try to get this working now, or should I file a separate issue? If we aren't doing this now, then what are you proposing we do with the pdf button in the toolbar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file separate issue. I would just keep the PDF where it is because it is small and useful and not really doing any harm, while providing key benefit for some users / sites.

Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments through rich.

Copy link
Member

@kkoreilly kkoreilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reviewed!

…ally), including WrapPi convenience function, along with associated tests, including for previously untested Truncate and IntMultiple functions.
…e gets set as fully transparent color, in which case text render mode should not render stroke.
…ugs, and MinAngleDiff for subtracting angles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants