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:
//Load the pdf document PdfLoadedDocument ldoc = new PdfLoadedDocument(path); var page = ldoc.Pages; 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);
Please provide feedback or comments
Did not find the solution Contact Support