Fix: Correct print scaling for Win2D PDF printing
Issue:
When you're printing pages using Win2D, especially when dealing with PDF documents that are rendered to CanvasBitmaps, you might run into some problems if your Windows display scaling isn't set to 100%. You might find that the edges of your printed PDF page are cut off, or the content might look like it's spilling out of the paper boundaries.
Cause:
The problem was happening because a part of the code, `PdfDocument.GetPage().RenderToStreamAsync()`, was being used without specifying certain rendering options (`PdfPageRenderOptions`). This meant the PDF page was being turned into an image stream using a default resolution (probably assuming 96 DPI for the PDF's original size) and wasn't taking into account the printer's actual DPI or your system's display scaling factor (`RawPixelsPerViewPixel`). Because of this, the `CanvasBitmap` created from this stream had pixel dimensions that didn't accurately match the intended physical size on paper when display scaling was active. This led to an incorrect layout by `CanvasPrintDocument`.
Solution:
I've made changes to the `LoadPDFPageBitmapsAsync` method in `Wino.Core.UWP/Services/PrintService.cs` to address this. Here's what I did:
1. I now get the printer's DPI from the `CanvasPrintDocument` (`sender.Dpi`).
2. I also get your current system display scaling factor (`DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel`).
3. For each page in your PDF, I calculate the target pixel dimensions needed to print the page at its correct physical size, using the printer's DPI.
4. Then, I figure out the necessary `DestinationWidth` and `DestinationHeight` (in DIPs) for `PdfPageRenderOptions` by dividing those target pixel dimensions by the `rawPixelsPerViewPixel`.
5. Finally, I call `PdfPage.RenderToStreamAsync()` using these calculated options.
This makes sure that the `CanvasBitmap` objects are created with pixel dimensions that are right for the printer's resolution and are correctly scaled according to your system's display settings. I ran some checks by simulating how this would work with display scaling at 100%, 125%, and 150%, and it confirmed that the calculations are now correct.
* Remove account rename dialog. Implement edit account details page.
* Remove unused folder definition.
* Adressing theming issues and adding reset button. Changing the UI a bit.
* Enable auto indent in initializer. Use service from the application.
* Adding color picker to acc setup dialog. Changing UI of edit acc details page.
* initial work for webview editor control
* moved more stuff to editor itself
* revert packages.props indention changes
* move alignment logic
* Migrate signature editor to new control
* move background to editor control
* Some polishing
* Fixed the corner glitch issue with dark theme.
---------
Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
* Very basic online search for gmail.
* Server side of handling offline search and listing part in listing page.
* Default search mode implementation and search UI improvements.
* Online search for Outlook.
* Very basic online search for gmail.
* Server side of handling offline search and listing part in listing page.
* Default search mode implementation and search UI improvements.
* Online search for Outlook.
* Online search for imap without downloading the messages yet. TODO
* Completing imap search.
* Remove AppCenter usage and libraries.
* Remove redundant pacakges and add the app insights sink.
* Diagnostic id support and manipulating telemetries.
* Handling of appdomain unhandled exceptions.
* Remove unused package identity package from mail project.
* Fixing printing.
* Fixing an issue where scrollviewer overrides a part of template in mail list. Adjusted zoomed out header grid's corner radius.
* IDLE implementation, imap synchronization strategies basics and condstore synchronization.
* Adding iCloud and Yahoo as special IMAP handling scenario.
* iCloud special imap handling.
* Support for killing synchronizers.
* Update privacy policy url.
* Batching condstore downloads into 50, using SORT extension for searches if supported.
* Bumping some nugets. More on the imap synchronizers.
* Delegating idle synchronizations to server to post-sync operations.
* Update mailkit to resolve qresync bug with iCloud.
* Fixing remote highest mode seq checks for qresync and condstore synchronizers.
* Yahoo custom settings.
* Bump google sdk package.
* Fixing the build issue....
* NRE on canceled token accounts during setup.
* Server crash handlers.
* Remove ARM32. Upgrade server to .NET 9.
* Fix icons for yahoo and apple.
* Fixed an issue where disabled folders causing an exception on forced sync.
* Remove smtp encoding constraint.
* Remove commented code.
* Fixing merge conflict
* Addressing double registrations for mailkit remote folder events in synchronizers.
* Making sure idle canceled result is not reported.
* Fixing custom imap server dialog opening.
* Fixing the issue with account creation making the previously selected account as selected as well.
* Fixing app close behavior and logging app close.
* Ground work for NET9 UWP switch.
* Add launch settings for Wino.Mail
* Added new test WAP project
* fix platforms in slnx solution
* ManagePackageVersionsCentrally set default
* Fixing assets and couple issues with the new packaging project.
* Add back markdown
* Fix nuget warnings
* FIx error in WAP about build tools
* Add build.props with default language preview
* Some AOT compilation progress.
* More AOT stuff.
* Remove deprecated protocol auth activation handler.
* Fix remaining protocol handler for google auth.
* Even more AOT
* More more AOT fixes
* Fix a few more AOT warnings
* Fix signature editor AOT
* Fix composer and renderer AOT JSON
* Outlook Sync AOT
* Fixing bundle generation and package signing.
---------
Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
* Plaintext links are now clickable and fixes dark mode.
- Change `AppxPackageDir` path from `C:\Users\bkaan\Desktop\Packages\` to `$(USERPROFILE)\Desktop\Packages\`, fixes error when building release.
- Plaintext links are now clickable, and match the same subtle style as Windows Mail.
- Remove `!important` from inline styles to allow Dark Reader to properly recolor the element.
* Implement setting for clickable plaintext link