Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP PDF printing

Tags:

c#

uwp

uwp-xaml

Is there a way to print PDF from UWP application? Other than rendering it as png or BitmapImage.

I had look at Microsoft printing sample and pdf rendering sample to achieve printing pdf by rendering it into bitmapimage. But, it looses the quality of the pdf. Would like to know if any other efficient method available without using libraries .

Edit(31/12/2018)

I tried to find direct solutions from Microsoft without using libraries. But, there isn't any so i used PDfSharp to solve my problem with the help of AppServiceBridge by Microsoft. I have used AppService bridge because PdfSharp isn't directly available for WinRT.

like image 285
Vignesh Avatar asked Aug 27 '18 16:08

Vignesh


1 Answers

I used a virtual printer in C# using the Github project: Microsoft/Windows-driver-samples/print/XPSDrvSmpl.

https://github.com/Microsoft/Windows-driver-samples/tree/master/print/XPSDrvSmpl

Installer: http://wixtoolset.org/

Application: Listen to internal port

Flow: Install printer and application from a single installer. User prints something with your driver while the application listens to the internal port. When data is sent the application picks it up. This is for XPS, can be converted to PDF, but the flow is similar no matter what you are printing.

Original answer:

https://stackoverflow.com/a/40370083/3850405

like image 110
Ogglas Avatar answered Nov 02 '22 23:11

Ogglas