Design and print PDF in Xamarin.Forms - xamarin

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?

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:
For Android: https://developer.xamarin.com/api/type/Android.Print.Pdf.PrintedPdfDocument/
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!

Related

How to share from an app to Xamarin macOS

I'm looking to add the availability to my application to receive content through share option from Note native apple application. I want my application appear in the list below.
Thanks, Robin.
You need to add the new project with the share extension and reference it in the main project.
One more critical part is that you need to declare in extension's info.plist which content you want to import.
Also of note, you indicated by the tag that you use Xamarin.Forms. It might be complicated to use Xamarin.Forms for the user interface in the Mac share extension. I would believe it is possible, but I don't think anyone did that and published info on how to do it.

Cannot add Judopay to Xamarin forms project

I am trying to include Judopay in my project, and I was able to add it to Android and iOS, but not to the Xamarin forms project. There is no NuGet to be included and I can't seem to add the component reference. Any idea on how can I add it? I cannot use any of these:
using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using JudoPayDotNet.Models;
Again, they only work on iOS or Android, but not Xam forms.
That is because they only provide platform implementations. You will need to tell your Forms app which implementation to use at what time.
The correct way to go about this is with some form of IoC, using dependency injection or service location. Luckily Xamarin Forms has this integrated:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/dependency-service/introduction/
Using the references from the Android or iOS projects in your shared code will likely not work completely or break things. Maybe not immediately but surely later on. (Except when there really is no platform-specific functionality, then you might get away with this.)

Download a zip file using xamarin forms app

I Am Newbie in Xamarin. Our Xamarin forms app supports Android and IOS. Most of the app functionality is written in PCL class library which is referred in the above platforms.
Now we need to download a zip file using this app. Some posts are suggesting to handle it in common PCL library and some are suggesting to handle it in respective native projects. I am bit confused, which is the better approach of the two. Are there any limitations in this approaches?
If possible could you please share a sample app. Thanks in advance.
You can write the code to download the file in PCL. For downloading file you can make use of HTTPClient. At the same time you have to call dependency service and write the dependent code in corresponding android/ios projects to specify the file output path.
https://developer.xamarin.com/recipes/ios/network/web_requests/download_a_file/ uses webClient which is written in android. You can use HTTPClient to get same result in PCL

What's the best way to implements multi language into the app?

I am developing my app (for android and ios) using nativescript and I have a question, my app will be used for many users around the world so I want to add the support for "chose the language" according the user.
What is the best way to support many language for my string values into the app? I tried to found some example about that but I can't find any information about the stuff.
Thanks in advance
I believe Dan Tamas is working on a plugin for this at the moment.
https://github.com/rborn/nativescript-i18n
This might be not the best way but I hope it could help if you are in urgent.
I have implemented multi-language successfully in my app by using Jed which is the Javascript implementation of GNU gettext .
Things to do are:
Install npm package jed + po2json
Prepare PO files and compile to json
Implements to XML pages by getting the source property from view-model
You can find more detail here:
How to internationalize app in NativeScript

Titanium - change language programmatically

I want to change the language of the app inside it. I want to allow the user to change the language from settings.
Is it possible?? because I can't find a setLocale() method or something similar.
Thanks.
I'm afraid this isn't possible using the build in tools. The build in tools are used by Android and iOS specifically to change the language based on the OS settings.
The way you can do this is by making it custom. Defining your own global function to get translations from (instead of the L() function). But this also requires you to put your translation files somewhere else.
The following line works although it is not documented. I think it will be documented soon and you will get a convenient way to change language on run time. Of course you will have define your own translation.
Ti.Locale.setLanguage("fr");
It is possible. I am using this module from the marketplace:
iOS: https://marketplace.appcelerator.com/apps/144434#!overview
Android: https://marketplace.appcelerator.com/apps/144430#!overview

Resources