|
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
PdfBitmap image = new PdfBitmap("../../Autumn Leaves.jpg");
//Bounds of the image.
RectangleF bounds = new RectangleF (PointF.Empty, new SizeF(300, 500));
//Draw image to PDF page.
page.Graphics.DrawImage(image, bounds);
//Create a new PDF pen.
PdfPen borderPen = new PdfPen(new PdfColor(System.Drawing.Color.Red));
//Set pen width.
borderPen.Width = 2;
//Draw border around the image.
page.Graphics.DrawRectangle(borderPen, bounds);
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
|
Hi Caleb,Thank you for contacting Syncfusion support.We can create borders around the image by drawing the rectangle along with the same bounds of the image. We have created a sample for drawing borders around the image for your reference. Please refer the below code snippet and sample for further details.
//Create a new PDF document.PdfDocument document = new PdfDocument();//Add a new PDF page.PdfPage page = document.Pages.Add();PdfBitmap image = new PdfBitmap("../../Autumn Leaves.jpg");//Bounds of the image.RectangleF bounds = new RectangleF (PointF.Empty, new SizeF(300, 500));//Draw image to PDF page.page.Graphics.DrawImage(image, bounds);//Create a new PDF pen.PdfPen borderPen = new PdfPen(new PdfColor(System.Drawing.Color.Red));//Set pen width.borderPen.Width = 2;//Draw border around the image.page.Graphics.DrawRectangle(borderPen, bounds);//Save the document.document.Save("output.pdf");//Close the document.document.Close(true);Please refer the UG link for more details,Please let us know if you have any concern.Regards,Chinnu