WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

Add support for page breaks in PrintHelper

Open deltakosh opened this issue 9 years ago • 9 comments

deltakosh avatar Apr 03 '17 20:04 deltakosh

Is it possible, to add support for the PrintTaskOptionDetails.GetFromPrintTaskOptions, to create own print options?

DocBrown101 avatar Apr 04 '17 08:04 DocBrown101

@deltakosh paging requires measuring, and measuring requires rendering. It's a job that goes beyond the responsibility of a single PrintHelper class. You can get some inspiration here: https://github.com/XamlBrewer/XamlBrewer.Uwp.PrintService.

XamlBrewer avatar Apr 04 '17 13:04 XamlBrewer

Why don't you think we could not extend the PrintHelper to do the same?

deltakosh avatar Apr 04 '17 16:04 deltakosh

Or even integrate your brillant work :)

deltakosh avatar Apr 04 '17 16:04 deltakosh

There are two issues that kept me from creating an easier reusable version of this framework:

  • You need read/write/delete access to the Visual Tree to render the controls on the print pages and measure them. This is hard if you don't know how the app's UI is build up. I do think that this can be done programmatically in the current UWP version (e.g. by opening an extra app window out of sight - a window provided by the printing framework), but I never tried this.
  • The entire paging algorithm is based on the capabilities of the RichTextBoxOverflow control. So any page that you want to print must have a RichTextBox as its root. In practice this means that the developer needs to define the pages twice: a version for the screen and a version for the printer. It would be nice to auto-generate a basic version of the RichTextBox-based version automatically and then let the developer fine-tune it, but I'm not sure that this can be done.

XamlBrewer avatar Apr 04 '17 17:04 XamlBrewer

  1. What I did for the PrintHelper was to ask the user to provide a canvas to host the rendering. This canvas can be set offscreen or under a panel by the dev.
  2. We could try a first version like this and then work on improving it in a 2nd version

deltakosh avatar Apr 04 '17 18:04 deltakosh

@deltakosh I don't mean to be pushy but can i know if you / someone is working on this? I am using Syncfusion pdf helper but Printing MarkdownTextBlock without Page Breaks is not so good.

avknaidu avatar Jul 05 '17 20:07 avknaidu

We did not get to this for 2.0, we will try again for 2.1. We are also open to contributions if anyone wants to pick this up ;)

nmetulev avatar Aug 21 '17 22:08 nmetulev

Added with #1964

nmetulev avatar May 15 '18 04:05 nmetulev