How to print PDF in UWP without loosing quality af

2019-04-01 07:14发布

After some investigation of printing in UWP I've highlighted:

  1. No native way to print PDF document directly from your app without redirecting this task to Edge or other similar program.
  2. There is a way to print XAML Elements (Image for example) using PrintDocument.
  3. There is a native way to render PDF into PNG using PdfDocument class

These three points gives us ability to print a PDF, but we have a problem here:

  1. After rasterization to PNG the quality of output document is quite poor.

Fortunately, PdfDocument allows you to increase the output resolution during rasterization, but...

  1. But it is memory consuming (x4 resolution leads to x32 memory consumption)
  2. But it is time consuming (x4 resolution leads to x7 time consumption)
  3. Even using x4 resolution of output image the quality is still so far from desired.

So I've created a sample which you can play with https://github.com/VitaliyPusan/UwpPrinting

Microsoft Edge for example can print PDF in pretty good quality and it do it fast and without additional memory consumption, but I have no idea how can I do the same thing.

Does anyone knows a better way to print PDF in UWP?

0条回答
登录 后发表回答