We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Rotate image width and height does not set

we have purchse PDF for .Net I am facing an issue rotate image when rotate image width and height does not proper set Please help.

using canvasWidth = 1138;
canvasHeight = 760;

System.IO.DirectoryInfo downloadedMessageInfo = new DirectoryInfo(ImagesPath);
int angle = 90;

            System.Drawing.Image myImage = System.Drawing.Image.FromFile(ImagesPath + ImageName);
            Bitmap bitmap = new Bitmap(myImage);

            Bitmap rotatedImage = null;
            if (counter == 1 || counter == 3)
                rotatedImage = new Bitmap(bitmap.Height, bitmap.Width);
            else if (counter == 2 || counter == 4)
                rotatedImage = new Bitmap(bitmap.Width, bitmap.Height);
            byte[] rotatedImageBytes = null;

            using (Graphics g = Graphics.FromImage(rotatedImage))
                // Set the rotation point to the center in the matrix
                g.TranslateTransform(bitmap.Width / 2, bitmap.Height / 2);
                // Rotate
                // Restore rotation point in the matrix
                g.TranslateTransform(-bitmap.Width / 2, -bitmap.Height / 2);
                // Draw the image on the bitmap
                g.DrawImage(bitmap, new System.Drawing.Point(0, 0));

                //rotatedImageBytes= Convert.ToByte(rotatedImage);

            ImageConverter converter = new ImageConverter();
            rotatedImageBytes = (byte[])converter.ConvertTo(rotatedImage, typeof(byte[]));

            Avicen.Common.ImpersonationService ImpService = new Avicen.Common.ImpersonationService(ImagesPath + ImageName, rotatedImageBytes, System.Configuration.ConfigurationManager.AppSettings["FileServerUserName"], System.Configuration.ConfigurationManager.AppSettings["FileServerDomain"], System.Configuration.ConfigurationManager.AppSettings["FileServerPassword"]);

            // rotatedImageBytes = System.Drawing.Image(rotatedImage);

            bool FileWritten = ImpService.WriteByteArrayToPdfFile();


Thanks for contacting support.

Your code includes only System.Drawing Classes and it is not complete that we can test your scenario with it. Could you please share your sample input file(s) along with complete code snippet where you are using Aspose.PDF methods. We will test the scenario in our environment and address it accordingly.