letsfindaway / OpenBoard

I'm using this fork to contribute features and fixes to the upstream project. In order to create good pull requests, I'm rebasing my feature branches, squashing and reordering commits, etc. If you fork this repository be aware that my development branches may rewrite history without prior notice.
http://openboard.ch/
GNU General Public License v3.0
9 stars 0 forks source link

[Bug] PDF scaling issue #162

Closed kaamui closed 7 months ago

kaamui commented 7 months ago

Hi Martin,

a teacher just reported me a new issue regarding PDF scaling. This time, not at export contrary to the cases we analysed together on #93

Are you OK to look at it ?

Describe the bug

When copying a page from one document to another, the copied page PDF background is not sized correctly. Restarting OpenBoard fixes the issue.

To Reproduce

  1. Launch OpenBoard
  2. Import BUG-PDF-DECALAGE-SOURCE.ubz
  3. Copy the page to a new document
  4. double click on the copied page

Expected behavior

A clear and concise description of what you expected to happen. The PDF page is correctly sized.

image

Actual behavior

A clear and concise description of what actually happened The PDF page is not correctly sized. Restarting OpenBoard fixes the issue. image

Screenshots

If applicable, add screenshots to help explain your problem.

Additional resources

PDF, images, sounds... anything useful to reproduce the bug BUG-PDF-DECALAGE-SOURCE.zip

Context

Additional context

letsfindaway commented 7 months ago

I can reproduce the problem here. Will look onto it later or over the weekend.

kaamui commented 7 months ago

Thank you ! Not related, but please also note that I had to disable the cleanupDocument feature. Every scenario where you insert new pages on a document already containing some produce the bug where document is immediately removed (in our context only) !

1.7.1 is going to be released ASAP.

letsfindaway commented 7 months ago

Thank you ! Not related, but please also note that I had to disable the cleanupDocument feature. Every scenario where you insert new pages on a document already containing some produce the bug where document is immediately removed (in our context only) !

I have seen that commit. I still believe the idea is useful. So let's keep this as work to do, same as the glitches.

1.7.1 is going to be released ASAP. :-)

letsfindaway commented 7 months ago

Some first observations using Gammaray:

The sceneTransform of the PDF is different in the error case.

Good: grafik

After copying: grafik

The difference is exactly the scaling problem. So next analysis should be where the sceneTransform is set.

Note that the transform matrix is the same in both cases, but the scale property is 0.75 in one case and 1 in the other case.

letsfindaway commented 7 months ago

Here: https://github.com/letsfindaway/OpenBoard/blob/6b27e9a84509511400678fe4cc8ac8d6713cc15c/src/adaptors/UBSvgSubsetAdaptor.cpp#L856 a PDF scaling factor is set when reading a document. Probably this factor is not set when copying a page.

kaamui commented 7 months ago

so UBGraphicsPDFItem::copyItemParameters should do the same ? (cp->setScale(this->scale()); ?)

letsfindaway commented 7 months ago

so UBGraphicsPDFItem::copyItemParameters should do the same ? (cp->setScale(this->scale()); ?)

Probably yes. I have not analyzed how a page is copied and have something else to do in the afternoon. But this was also my idea for a try.

kaamui commented 7 months ago

I tried and it's working. If you don't mind, I commit the fix so I can move on building a new version for the test team.

Thank you for the help !