Insert Image to Pdf Document

Hi I am doing some testing with Aspose Barcode module and trying to insert them to pdf. I am having issues inserting image to existing pdf document. Inserted image is upside down. Here is the code that i used to insert the image.

Dim pdfDocument As New Aspose.Pdf.Document(MyPdfFile)

Try

Dim pageCount As Integer = pdfDocument.Pages.Count

For Each MyPage As Aspose.Pdf.Page In pdfDocument.Pages

'add image to Images collection of Page Resources

MyPage.Resources.Images.Add(myBarCodeImage)

'using GSave operator: this operator saves current graphics state

MyPage.Contents.Add(New Aspose.Pdf.Operator.GSave())

'create Rectangle and Matrix objects

Dim matrix As New Aspose.Pdf.DOM.Matrix

matrix.A = 20

matrix.B = 0

matrix.C = 0

matrix.D = 30

matrix.E = 60 'X Coordinate

matrix.F = 220 'Y Coordinate

'using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed

MyPage.Contents.Add(New Aspose.Pdf.Operator.ConcatenateMatrix(matrix))

Dim ximage As XImage = MyPage.Resources.Images(MyPage.Resources.Images.Count)

'using Do operator: this operator draws image

MyPage.Contents.Add(New Aspose.Pdf.Operator.Do(ximage.Name))

'using GRestore operator: this operator restores graphics state

MyPage.Contents.Add(New Aspose.Pdf.Operator.GRestore())

Next

pdfDocument.Save("test.pdf")

Catch ex As Exception

Throw ex

Finally

'imageStream.Close()

pdfDocument.Dispose()

End Try

Any help would be greatly appreciated.

Please ignore this post, i found my answer. My Matrix coordinate should have been

'create Rectangle and Matrix objects

Dim matrix As New Aspose.Pdf.DOM.Matrix

matrix.A = 20

matrix.B = 0

matrix.C = 0

matrix.D = -30

matrix.E = 60 'X Coordinate

matrix.F = 220 'Y Coordinate

Thanks