Tue Feb 24, 2015 11:55 am
This is the code:
PdfImage imgSquare;
//open document
document = new PdfDocument();
page = document.Pages.Add(PdfPageSize.A4, new PdfMargins(0f));
// red rectangle
PdfSolidBrush brush3 = new PdfSolidBrush(Color.FromArgb(255, 227, 37, 38));
RectangleF rect1 = new RectangleF(0, 0, 500, 300);
page.Canvas.DrawRectangle(brush3, rect1);
imgSquare = PdfImage.FromFile(path + @"\YellowSquare.png");
float scaleF = 2f;
// yellow square
float width = imgSquare.Width * scaleF;
float height = imgSquare.Height * scaleF;
page.Canvas.DrawImage(imgSquare, 10, 10, width, height);
page.Canvas.Restore(state);
//save document
document.SaveToFile(@"c:\temp\test.pdf");
//close document
document.Close();
And see the image in attachment
Regards,
Philippe
Login to view the files attached to this post.