Hi,
Hi Alan,
Thanks for contacting support.
The Image position is calculated from bottom left of page, so in order to render it on top-left position, please get page Height information to place image accordingly. Please try using following code snippet to accomplish your requirement and for your reference, I have also attached the output generated over my end.
[C#]
Document pdfDocument = new Document();
// Set coordinates
int lowerLeftX = 10;
int lowerLeftY = 10;
int upperRightX = 50;
int upperRightY = 50;
// Get the page where the image needs to be added
Page page = pdfDocument.Pages.Add();
// Load image into stream
FileStream imageStream = new FileStream("c:/pdftest/logoSpin.png", FileMode.Open);
// Add the image to the Images collection of Page Resources
page.Resources.Images.Add(imageStream);
// Using GSave operator: this operator saves the current graphics state
page.Contents.Add(new Operator.GSave());
// Create Rectangle and Matrix objects
// Get page height information to place the image
Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(lowerLeftX, page.PageInfo.Height - lowerLeftY, upperRightX, page.PageInfo.Height - upperRightY);
Matrix matrix = new Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });
// Using ConcatenateMatrix (concatenate matrix) operator: defines how the image must be placed
page.Contents.Add(new Operator.ConcatenateMatrix(matrix));
XImage ximage = page.Resources.Images[page.Resources.Images.Count];
// Using Do operator: this operator draws the image
page.Contents.Add(new Operator.Do(ximage.Name));
// Using GRestore operator: this operator restores the graphics state
page.Contents.Add(new Operator.GRestore());
// Save the PDF file
pdfDocument.Save("c:/pdftest/ConvertedFile.pdf");