// Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page to the document
PdfPage page = document.Pages.Add();
//Create PDF graphics for a page
PdfGraphics graphics = page.Graphics;
//Get image
var icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.logo);
var imageStream = new MemoryStream();
//Compress image
icon.Compress(Bitmap.CompressFormat.Png, 0, imageStream);
//Create PdfBitmap image from stream
PdfBitmap image = new PdfBitmap(imageStream);
//Draw image
graphics.DrawImage(image, new Rectangle(0, 0, 200, 100));
//Save the document to the stream
MemoryStream stream = new MemoryStream();
document.Save(stream);
//Close the document
document.Close(true); |