Category / Section
How to rotate and add border around the layout of image.
1 min read
How to rotate and add border around the layout of image:
It is possible to rotate and draw border around the layout of an image, by drawing the rectangle along with the same bounds of an image. Below is the code snippet:
C#:
//Load the pdf document PdfLoadedDocument ldoc = new PdfLoadedDocument(path); var page = ldoc.Pages[0]; PdfGraphics grapchics = page.Graphics; //Save the graphics state before rotating grapchics.Save(); grapchics.RotateTransform(-20); //string imagePath = Server.MapPath("~/App_Data/logo.png"); PdfBitmap image = new PdfBitmap(imagePath); grapchics.DrawImage(image, new PointF(50, 450)); //Draws border within the bounds of an image grapchics.DrawRectangle(PdfPens.Black, new RectangleF(50, 450, image.Width, image.Height)); //Restore the graphics state once rotated. grapchics.Restore(); //Save the document and dispose it. ldoc.Save("Output.pdf"); ldoc.Close(true);
Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/146113/ze/PdfBorder790601916