Design and print PDF in Xamarin.Forms

2019-09-20 05:48发布

I am working on a Xamarin.Forms project.

I have to create an ID card from the details provided, in a certain format and print the same.

How can this be done?

Has anyone tried something like this?

1条回答
Luminary・发光体
2楼-- · 2019-09-20 06:40

Disclaimer: I have NOT tried the following solution myself.

There is no out-of-the-box support in Xamarin.Forms for printing PDF.

The best practice, in terms of safety and native-performance, would be to use Dependency Injection by defining an interface in the portable (CPL or .NET Standard) project and implementing the actual printing code in the native projects you wish to target.

The following are the APIs for their respective platforms:

  1. For Android: https://developer.xamarin.com/api/type/Android.Print.Pdf.PrintedPdfDocument/

  2. For iOS: https://developer.xamarin.com/api/type/MonoTouch.UIKit.UIPrintInteractionController/

More of the same:

https://www.syncfusion.com/kb/8767/how-to-print-pdf-documents-in-xamarin-forms-platform

Hope it helps. Cheers!

查看更多
登录 后发表回答