rnote icon indicating copy to clipboard operation
rnote copied to clipboard

Some PDF objects are not rendered in the correct position

Open tubbadu opened this issue 1 year ago • 2 comments

Describe the bug
Some objects of the PDF are rendered in the wrong position, making the document very difficult to read

To Reproduce
Steps to reproduce the behavior:

  1. open the attached PDF with rnote
  2. import is as vector
  3. see it's rendered wrong

Expected behavior
The pdf is rendered correctly

Screenshots
how it's rendered by rnote: image

interested pdf: TESTPDF.pdf

how it should be rendered (screenshot from Okular): image

This does not happens when importing the pdf as bitmap instead of vector

Desktop (please complete the following information):

  • OS: EndeavourOS
  • App Version: Rnote v0.11.0
  • Installation Source: Archlinux main repository ("extra/rnote")
  • Desktop Environment: KDE Plasma 6.2.0
  • Display Server: Wayland
  • Input Source: Mouse and Keyboard

tubbadu avatar Oct 11 '24 10:10 tubbadu

Related : #526 As explained in https://github.com/flxzt/rnote/issues/526#issuecomment-1439170212, either a conversion issue in poppler (pdf to svg) or in the rendering (usvg/cairo)

Doublonmousse avatar Oct 12 '24 08:10 Doublonmousse

After a quick test using pdf2svg (poppler -> cairo to do a pdf to svg conversion) it seems to work fine doing that. So it's probably an usvg-related rendering issue.

In fact converting first the pdf to svg (which is rendered correctly) then importing it within rnote will show it incorrectly. Gonna need a little bit more time to find why and link to an usvg issue

Version used :

pdf2svg 0.2.3_6
poppler 24.04.0
cairo 1.18.2

Doublonmousse avatar Oct 12 '24 16:10 Doublonmousse

I looked at this here https://github.com/linebender/resvg/issues/877 but didn't necessarily go further or report back here.

I don't have the reason behind the presence of the simplification step for usvg though. If this is to save space, maybe we can reconsider doing so because of the negative effects on rendered svg.

The configuration for the strength of the simplification in rnote is here https://github.com/flxzt/rnote/blob/a46675398338232325b14d5e4a97047e34c592e3/crates/rnote-engine/src/strokes/vectorimage.rs#L145-L156 then applied here https://github.com/flxzt/rnote/blob/a46675398338232325b14d5e4a97047e34c592e3/crates/rnote-engine/src/strokes/vectorimage.rs#L169

The issue is that the simplification is a simple rounding of floating point values for each element (see : https://github.com/linebender/resvg/blob/881ed7be8327972d3ce3a3a4d863a8c2c009ab84/crates/usvg/src/writer.rs#L1405) but it does not take into account the actual nested structure of the xml. So if you have a transform with very large values inside of a transform with very small values, the rounding done on the outer one with the small values will result in a very large coordinate change because of the multiplication by the inside transform.

Doublonmousse avatar Jul 05 '25 08:07 Doublonmousse