Support

Knowledge Base - How to create an image page using Xamarin? (Android)

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();
}
Applies To

RadaeePDF SDK for Android, RadaeePDF SDK for Xamarin

Details

Created : 2017-03-17 14:11:36, Last Modified : 2017-11-17 09:27:39

Order history

Login to handle your order history.