Rank: Newbie
Groups: Registered
Joined: 6/29/2016(UTC) Posts: 3
Thanks: 1 times
|
Hi, i want to insert an image into a Pdf document. The image gets inserted using the below code. However, other page content gets lost. How do I avoid this? Code:
var form = new PdfForms();
var doc = PdfDocument.Load("filepath", form);
Bitmap bmp = new Bitmap(logo, 165, 38);
var bi = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb);
var bitmap = new PdfBitmap(bmp.Width, bmp.Height, BitmapFormats.FXDIB_Argb, bi.Scan0, bi.Stride);
var image = PdfImageObject.Create(doc);
image.SetBitmap(bitmap);
image.SetMatrix(1, 0, 0, 1, 0, 0);
image.Transform(165, 0, 0, bmp.Height, 50, 700);
var page = doc.Pages[0];
page.PageObjects.InsertObject(image, -1);
page.GenerateContent();
|