Rotate Image in pdf page

C#
Hi,
How can we rotate the pdf/png base64 content and add it to a document and generate a pdf.
There are going to be multiple images in the pdf each in each page roated, just the image not the pdf page and the application would be deployed in linux container.
Thanks

@sajanpokhrel

Would you kindly share any sample base64 string for our reference? We will use it to generate a PDF with rotated image and share our feedback with you. You can paste the string in a .txt file and share with us.

base64.zip (7.4 KB)
attached the zip file which has text file in it.
Thanks

@sajanpokhrel

Looks like the shared base64 string is not a valid one. Nevertheless, we tested using a sample base64 image using below code snippet and were able to generate a PDF with rotated image:

Document doc = new Document();
doc.Pages.Add();

var img = Convert.FromBase64String(File.ReadAllText(dataDir + "b64.txt"));
var imageStream = new MemoryStream(img);
imageStream.Position = 0;

ImageStamp stamp = new ImageStamp(imageStream);
stamp.HorizontalAlignment = HorizontalAlignment.Center;
stamp.VerticalAlignment = VerticalAlignment.Center;
//stamp.Opacity = 1;
stamp.Rotate = Rotation.on180;

doc.Pages[1].AddStamp(stamp);

doc.Save(dataDir + "rotateImage.pdf");

b64.zip (62.7 KB)
rotateImage.pdf (105.0 KB)

Thanks for the response.
the base64 I attached was a pdf,
I wanted to make the end result look like this attached imagesampImg.PNG (23.5 KB)
. how can I set the position and margins?

@sajanpokhrel

You can specify height/width of image stamp as well as margins and dimensions of Page using Page.PageInfo.Margins and other properties while generating the PDF. Please let us know in case you still notice any issues.

I was able to specify the page and image height/width and margins but how do I add that image to a specefic postion in a page?

@sajanpokhrel

ImageStamp can be assigned with particular position by specifying it XIndent and YIndent properties. Please note that any type of vertical or horizontal alignment would not work if position parameters are specified.

Thank You for the response, I was able to get the desired outcome.