This article shows, how to add an image, from the device storage, to a pdf. (A premium license is required)
private void createPDF()
{
Global.Init(this);
Document mDocument = new Document();
mDocument.Create("/sdcard/test.pdf");
mDocument.SetCache(Global.TmpPath + "/temp.dat");
NewPage(mDocument, 0, 210, 297);
mDocument.Save();
mDocument.Close();
}
private void NewPage(Document document, int pageno, float w, float h)
{
Page page = document.NewPage(pageno, w, h);//create A4 paper
PageContent content = new PageContent();
content.Create();//create content, do not forget.
content.GSSave();
Bitmap bmp = BitmapFactory.DecodeFile("/sdcard/image.png");
Document.DocImage dimg = document.NewImage(bmp, true);
bmp.Recycle();
ResImage rimg = page.AddResImage(dimg);
Com.Radaee.Pdf.Matrix mat = new Com.Radaee.Pdf.Matrix(w, h, 0, 0);
content.GSSetMatrix(mat);
mat.Destroy();
content.DrawImage(rimg);
content.GSRestore();
//add content to page
page.AddContent(content, true);
content.Destroy();
page.Close();
}
RadaeePDF SDK for Xamarin
Created : 2017-03-17 14:11:36, Last Modified : 2022-03-21 17:51:58