Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144580 | May 13,2019 11:28 AM UTC | May 14,2019 12:35 PM UTC | Xamarin.Forms | 1 |
![]() |
Tags: PDF |
I'm creating a PDF on the fly using Syncfusion and Xamarin Forms. Everything is going well in iOS, but in Android, it failed to locate the image (logo).
followed syncfusion PDF getting started but even that it's not working. The image is located in android's resource/drawable. I did also added it in assets.
This is the working code in xamarin forms iOS
//Load the image
Stream imageStream = System.IO.File.OpenRead("logo.jpg");
//Load the image from the stream
PdfBitmap image = new PdfBitmap(imageStream);
Unfortunately, even this doesn't work on Android
//Load the image
Stream imageStream = DependencyService.Get<ISave>().LoadFromFile(@"logo.jpg");
//Load the image from the stream
PdfBitmap image = new PdfBitmap(imageStream);
Your help is appreciated as I'm stuck on this for 3 days now.
var context = Android.App.Application.Context;
using (var drawable = Xamarin.Forms.Platform.Android.ResourceManager.GetDrawable(context, fileName))
using (var bitmap = ((BitmapDrawable)drawable).Bitmap)
{
var stream = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Png, 100, stream);
bitmap.Recycle();
return stream.ToArray();
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.