Keyword does not name a type

Hi all,

i try to use this Sample:

'open
document

Dim pdfDocument As New Document("input.pdf")

'set coordinates

Dim lowerLeftX As Integer = 100

Dim lowerLeftY As Integer = 100

Dim upperRightX As Integer = 200

Dim upperRightY As Integer = 200

'get the page where image needs to be added

Dim page As Page = pdfDocument.Pages(1)

'load image into stream

Dim imageStream As New FileStream("aspose-logo.jpg", FileMode.Open)

'add image to Images collection of Page Resources

page.Resources.Images.Add(imageStream)

'using q operator: this operator saves current graphics state

page.Contents.Add(New Operator.q())

'create Rectangle and Matrix objects

Dim rectangle As New Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY)

Dim matrix As New Matrix(New Double() { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY })

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

page.Contents.Add(New Operator.cm(matrix))

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

'using Do operator: this operator draws image

page.Contents.Add(New Operator.Do(ximage.Name))

'using Q operator: this operator restores graphics state

page.Contents.Add(New Operator.Q())

'save updated document

pdfDocument.Save("output.pdf")



But every Operator is underlined with: Keyword does not name a type.

Can anyone help me to run this sample?

Thanks and Regards
Winfried

Hi Winfried,

Thanks for using our products.

Since the release of Aspose.Pdf for .NET 6.7.0, we made some changes in operator class names to give them some user friendly names. I think you have copied the above stated code from offline product documentation. In order to add image to existing PDF files, please follow the instructions specified over Add Image in an Existing PDF File

I would also recommend you to please visit [Changes in Operator class names](http://www.aspose.com/docs/display/pdfnet/Changes+in+Operator+class+names).

We apologize for your inconvenience.

Hi Nayyer,

thanks for your quick response.
I used the new Sample, but i had the same message with the new samples. Here you can see what i have to change, now it is working. Pls look at the attached file.

Thanks and Regards
Winfried

Hi Winfried,

Thanks for sharing the details.

I have tested the scenario using Aspose.Pdf for .NET 8.5.0 in VisualStudio 2010 application where I have used the following code snippet and I am unable to notice any problem.

'open document
Dim pdfDocument As New Document("C:/PDFTEST/Location-map.pdf")

'macros for dimensions
Dim lowerLeftX As Integer = 100
Dim lowerLeftY As Integer = 100
Dim upperRightX As Integer = 200
Dim upperRightY As Integer = 200

'get the page where image needs to be added
Dim page As Page = pdfDocument.Pages(1)

'load image into stream
Dim imageStream As New FileStream("c:/pdftest/Florencesans_FontIssue.png", FileMode.Open)

'add image to Images collection of Page Resources
page.Resources.Images.Add(imageStream)

'usign GSave operator: this operator saves current graphics state
page.Contents.Add(New Aspose.Pdf.Operator.GSave())

'create Rectangle and Matrix objects
Dim rectangle As New Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY)
Dim matrix As New Aspose.Pdf.DOM.Matrix(New Double() {rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY})

'usign ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
page.Contents.Add(New Aspose.Pdf.Operator.ConcatenateMatrix(matrix))

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

'usign Do operator: this operator draws image
page.Contents.Add(New Aspose.Pdf.Operator.Do(ximage.Name))

'usign GRestore operator: this operator restores graphics state
page.Contents.Add(New Aspose.Pdf.Operator.GRestore())

'save updated document
pdfDocument.Save("c:/pdftest/WithImage_output.pdf")

Hi,

this is what i posted. The Online-Sample is not working for me. Did you see the difference to my first posting?

I had posted my solution, for me is every thing working, maybe you can correct the Online and Offline Samples. :wink:

Winfried

Hi Winfried,


Thanks for sharing the details.

In my earlier post, I interpreted the red highlight rectangles as areas where you are still getting the error message and missed your point that when using code snippet from online documentation, the problem is resolved. As stated earlier, the offline documentation is bit old and we are working on preparing the offline documentation based on contents present on live server. As soon as the offline version becomes identical to online version, we would be more than happy to update you with the status of correction.

We are sorry for your inconvenience.