Articles in this section
Category / Section

How to rotate and add border around the layout of image.

2 mins read

How to rotate and add a border around the layout of an image:

It is possible to rotate and draw a border around the layout of an image by drawing the rectangle along the same bounds as the image. Below is the code snippet:

C#:

  // Load the PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument(path);

var page = ldoc.Pages[0];
PdfGraphics graphics = page.Graphics;
// Save the graphics state before rotating
graphics.Save();
graphics.RotateTransform(-20);
// string imagePath = Server.MapPath("~/App_Data/logo.png");
PdfBitmap image = new PdfBitmap(imagePath);
graphics.DrawImage(image, new PointF(50, 450));
// Draws border within the bounds of the image
graphics.DrawRectangle(PdfPens.Black, new RectangleF(50, 450, image.Width, image.Height));
// Restore the graphics state once rotated.
graphics.Restore();
// Save the document and dispose of it.
ldoc.Save("Output.pdf");
ldoc.Close(true);

 

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/146113/ze/PdfBorder790601916


Note:

Starting with v16.2.0.x, if you reference Syncfusion® assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.

 

Conclusion

I hope you enjoyed learning about how to rotate and add border around the layout of image.

You can refer to our PDF feature tour page to learn about its other groundbreaking feature representations. You can also explore our documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied