Jojo-Schmitz / MuseScore

MuseScore is a open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
http://musescore.org
Other
35 stars 3 forks source link

MS 3.7 doesn't export PDF in landscape format #601

Closed zorba77 closed 1 week ago

zorba77 commented 2 weeks ago

MS 3.7 exports all pdf in portrait format, even if the score is set in landscape format. the consequence is that the pdf is cut on the right. I attached a score with 2 pdf for A4 and A5. The same happens with the parts. This is a very problematic bug, since the PDF export is essential to create parts to share.

PDF.zip

Jojo-Schmitz commented 2 weeks ago

Confirmed :-(

Jojo-Schmitz commented 2 weeks ago

May relate to #16617

zorba77 commented 2 weeks ago

May relate to musescore#16617

I don't know, I don't tried to print a landscape score, I only created a PDF. SVG and PNG export are ok. My OS is Linux.

Jojo-Schmitz commented 2 weeks ago

There's this code in all PDF exporting functions:

      printer.setPageOrientation(size.width() > size.height() ? QPageLayout::Landscape : QPageLayout::Portrait);

Deleting those seems to fix the issue, I just don't understand why

Hmm, https://doc.qt.io/qt-5/qpagedpaintdevice.html#setPageOrientation says:

You should call this before calling QPainter::begin(), or immediately before calling newPage() to apply the new orientation to a new page. You should not call any painting methods between a call to setPageOrientation() and newPage() as the wrong paint metrics may be used.

I just wonder why that apparently wasn't a problem in MuseScore 3.6.2?

zorba77 commented 2 weeks ago

I can confirm that the issue is closed for a single page score in landscape. The error remains exporting multipage scores or score with parts. In these situations only the first page is set in landscape (if needed). I attached an old score, but this is true also for all my scores. 20_inno tedesco.zip

Jojo-Schmitz commented 2 weeks ago

Darn... I had sort of anticipated that, so I made sure that this setting is done directly before all pageNew() calls.

zorba77 commented 2 weeks ago

I'm reading the last commit, if (!firstPage) { printer.setPageOrientation(size.width() > size.height() ? QPageLayout::Landscape : QPageLayout::Portrait); printer.newPage(); }

Maybe is this the problem? The problematic code was removed only for the first page.

Jojo-Schmitz commented 2 weeks ago

I followed the Qt documentation above You should call this ..., or immediately before calling newPage()

It seems a problem only with score (portrait) with parts (landscape) in one single file, right?

Jojo-Schmitz commented 2 weeks ago
Jojo-Schmitz commented 2 weeks ago

We'd need someone on Mac to test this too, these savePDF() methods do have some platform-dependant code in them

Jojo-Schmitz commented 2 weeks ago

Please test, I've force-pushed it to the 3.x branch

zorba77 commented 1 week ago

Tests exporting PDF combined in a single file:

-export portrait score and mixed parts in separated files: OK -export landscape score and mixed parts in separated files: OK

Today I will do some experiments with printer

Jojo-Schmitz commented 1 week ago

All on Linux that is, right?

zorba77 commented 1 week ago

All on Linux that is, right?

Yes, KUbuntu LTS 22.04

Jojo-Schmitz commented 1 week ago

Fixed for Linix and Windows, let's close and reopen if Mac still has an issue

zorba77 commented 1 week ago

I can confirm that a landscape score is printed rightly under linux