logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Monday, September 5, 2016 6:09:39 PM(UTC)
 
MischaS Posted: Tuesday, July 5, 2016 7:29:11 AM(UTC)
 
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();