Home > Software engineering >  How to print RichEditBox with PrintHelper?
How to print RichEditBox with PrintHelper?

Time:06-23

I want to Print RichEditBox, i am using Windows Community Toolkit helper class called PrintHelper. i tested this code:

<Grid x:Name="PrintableContent">
  <RichEditBox Name="txt"/>
</Grid>

and

txt.Document.SetText(Microsoft.UI.Text.TextSetOptions.None, long text);

_printHelper = new PrintHelper(PrintableContent);
var printHelperOptions = new PrintHelperOptions(false);
printHelperOptions.Orientation = PrintOrientation.Default;
await _printHelper.ShowPrintUIAsync(WinRT.Interop.WindowNative.GetWindowHandle(this), "Windows Community Toolkit Sample App", printHelperOptions, true);

The problem is that not all text is printed And only the visible part is printed enter image description here

How can I print all available text?

CodePudding user response:

This is expected behavior for the Print function. The print API can't print the invisible text. The print function is like a screenshot. If you want to show all the text, you have to make all the text visible.

  • Related