Maximize productivity with
30% off* for a limited time
using BOOSTDEV30.
Includes 3- and 5-packs.
*Some exclusions may apply.New Product LaunchBoldDesk: Help desk ticketing software starts at $10 for 3 agents.
Try it for free.
// 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); |