I am having problems in Xamarin forms in android when converting an image that resides in the drawable repository of resources, but at the time of loading the image in a variable to later make the conversion to iText.Layout.Element.Image (which later this image it will go to a pdf using itext 7), they give me compatibility errors only for shitting the image in the variable, according to the documentation.
I suppose that later in the apk, when it is not executed in debug mode, these images will be available. There are some similar questions, but I have not seen any where the image starts as local
var image5 = new iText.Layout.Element.Image("logo.jpg");
using (MemoryStream memoryStream1 = new MemoryStream())
{
image5.Save(memoryStream1, ImageFormat.Png);
byte[] bytes = memoryStream1.ToArray();
}
To later process the image to incorporate it into the pdf document
ImageData imageData = ImageDataFactory.Create(bytes);
iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData);
document.Add(image);
But I get the Save() method error from System.Drawing and not how to fix it
The other code I have is:
var image20 = new Xamarin.Forms.Image();
Assembly assembly = this.GetType().GetTypeInfo().Assembly;
byte[] imgByteArray = null;
using (var s = assembly.GetManifestResourceStream("C:\\Users\\..\\logotipo.PNG"))
{
if (s != null)
{
var length = s.Length;
imgByteArray = new byte[length];
s.Read(imgByteArray, 0, (int)length);
image20.Source = ImageSource.FromStream(() => s);
}
}
ImageData imageData9 = ImageDataFactory.Create(imgByteArray);
iText.Layout.Element.Image image9 = new
iText.Layout.Element.Image(imageData9);
I am having problems in Xamarin forms in android when converting an image that resides in the drawable repository of resources, but at the time of loading the image in a variable to later make the conversion to iText.Layout.Element.Image (which later this image it will go to a pdf using itext 7), they give me compatibility errors only for shitting the image in the variable, according to the documentation.
I suppose that later in the apk, when it is not executed in debug mode, these images will be available. There are some similar questions, but I have not seen any where the image starts as local
var image5 = new iText.Layout.Element.Image("logo.jpg");
using (MemoryStream memoryStream1 = new MemoryStream())
{
image5.Save(memoryStream1, ImageFormat.Png);
byte[] bytes = memoryStream1.ToArray();
}
To later process the image to incorporate it into the pdf document
ImageData imageData = ImageDataFactory.Create(bytes);
iText.Layout.Element.Image image = new iText.Layout.Element.Image(imageData);
document.Add(image);
But I get the Save() method error from System.Drawing and not how to fix it
The other code I have is:
var image20 = new Xamarin.Forms.Image();
Assembly assembly = this.GetType().GetTypeInfo().Assembly;
byte[] imgByteArray = null;
using (var s = assembly.GetManifestResourceStream("C:\\Users\\..\\logotipo.PNG"))
{
if (s != null)
{
var length = s.Length;
imgByteArray = new byte[length];
s.Read(imgByteArray, 0, (int)length);
image20.Source = ImageSource.FromStream(() => s);
}
}
ImageData imageData9 = ImageDataFactory.Create(imgByteArray);
iText.Layout.Element.Image image9 = new
iText.Layout.Element.Image(imageData9);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.