I am using Xamarin Android and on line "document.WriteTo(outPut);" I am getting a compile time error. The equivalent code compiles in Java, but using Xamarin and c# I am having some type of casting/conversion issue. Does anyone know how to fix this? What I am trying to do is take my created pdf and turn it into a byte array.
Byte[] MakePDFFromImages(){
// open a new document
PrintAttributes printAttributes = new PrintAttributes.Builder().
SetColorMode(Android.Print.PrintColorMode.Color).
SetMediaSize(PrintAttributes.MediaSize.IsoA4).
SetResolution(new PrintAttributes.Resolution("zooey","test", 450, 700)).
SetMinMargins(PrintAttributes.Margins.NoMargins).
Build();
PrintedPdfDocument document = new PrintedPdfDocument (Activity.BaseContext, printAttributes);
// start a page
Android.Graphics.Pdf.PdfDocument.Page page = document.StartPage(0);
ImageView imageView = new ImageView (Activity.BaseContext);
imageView.SetImageBitmap (_imageArray [0]);
imageView.Draw(page.Canvas);
document.FinishPage(page);
ByteArrayOutputStream outPut = new ByteArrayOutputStream();
try {
document.WriteTo(outPut);
document.Close();
outPut.Close();
}
catch(Exception){
}
return outPut.ToByteArray();
}