Need help assigning an annotation object

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
colelaus
Posts: 3
Joined: Sun Dec 29, 2013 2:32 am

Need help assigning an annotation object

Post by colelaus » Sun Dec 29, 2013 2:52 am

I'm attempting to implement in MS Access 2007 example code from the GdPicture online documentation that imports a file, adds and rubber stamp, rotates it and then displays it. However, when I attempt to replicate this code in an access 2007 vba environment, my attempt to assign the returned AnnotationRubberStamp to the AnnotationRubberStamp object results in a 'run-time error 91, object or with block variable not set.

Following is the code supplied in the GdPicture examples:

Code: Select all

  Dim annot As AnnotationRubberStamp = oAnnotationManager.AddRubberStampAnnot(Color.Red, 0, 0, oGdPicturePDF.GetPageWidth / 72, oGdPicturePDF.GetPageHeight / 72, "APPROVED")
I've converted this for use with Access vba to the following:

Code: Select all

    Dim annot As AnnotationRubberStamp
    annot = oAnnotationManager.AddRubberStampAnnot(-16777216, 0, 0, 3, 3, "APPROVED")
Use of the following AddRubberStampAnnot statement without assigning the return value works fine

Code: Select all

oAnnotationManager.AddRubberStampAnnot -16777216, 0, 0, 3, 3, "APPROVED"
so I know my method arguments are OK.

Any help to get me over this hump would be appreciated. I'm am currently evaluating this software and without understanding why this will not work I can't move forward.

Complete code from the GdPicture website follows:

Code: Select all

'The following code assumes that a GdViewer called GdViewer1 has been painted on the form.
Dim oGdPicturePDF As New GdPicturePDF
oGdPicturePDF.LoadFromFile("c:\test.pdf", False)
GdViewer1.DisplayFromGdPicturePDF(oGdPicturePDF)
Dim oAnnotationManager As New AnnotationManager
oAnnotationManager.InitFromGdViewer(GdViewer1)
oAnnotationManager.SelectPage(1)
Dim annot As AnnotationRubberStamp = oAnnotationManager.AddRubberStampAnnot(Color.Red, 0, 0, oGdPicturePDF.GetPageWidth / 72, oGdPicturePDF.GetPageHeight / 72, "APPROVED")
annot.Rotation = 20
oAnnotationManager.SaveAnnotationsToPage()
oAnnotationManager.Close()
GdViewer1.Redraw()
My complete code where GdViewer8 is my GdViewer control:

Code: Select all

    Dim Forecolor As Long
    
    Dim oGdPicturePDF As New GdPicture_NET_10.GdPicturePDF
    Dim oAnnotationManager As New annotationManager
    
    oGdPicturePDF.LoadFromFile "c:\_temp\DOC120613.pdf", True
    GdViewer8.DisplayFromGdPicturePDF oGdPicturePDF
    
    oAnnotationManager.InitFromGdPicturePDF oGdPicturePDF
    oAnnotationManager.SelectPage 1
    Forecolor = GdViewer8.ARGBI(255, 0, 0, 0)
    '
    ' Calling the following without using the AnnotationRubberStamp return value
    '  works just fine
    '
    oAnnotationManager.AddRubberStampAnnot Forecolor, 0, 0, 3, 3, "APPROVED"
    '
    ' Calling the following attempting to set the AnnotationRubberStamp
    '  return value to a AnnotationRubberStamp object causes a
    '  run-time error '91', object or with block variable not set
    '
    Dim annot As AnnotationRubberStamp
    annot = oAnnotationManager.AddRubberStampAnnot(Forecolor, 0, 0, 3, 3, "APPROVED")
    annot.Rotation = 20
    
    oAnnotationManager.SaveAnnotationsToPage
    oAnnotationManager.Close
    GdViewer8.ReloadAnnotations
    GdViewer8.Redraw

colelaus
Posts: 3
Joined: Sun Dec 29, 2013 2:32 am

Re: Need help assigning an annotation object

Post by colelaus » Sun Dec 29, 2013 3:00 am

It happens almost everytime.... right after posting a problem that has me going nuts I figure out the problem. Arghh. So simple...

My code should have used the SET command as in:

Code: Select all

    Dim annot As AnnotationRubberStamp
    Set annot = oAnnotationManager.AddRubberStampAnnot(-16777216, 0, 0, 3, 3, "APPROVED")
I knew it had to be something simple.

As Roseanne Roseannadanna always said... never mind.

User avatar
Loïc
Site Admin
Posts: 5575
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Need help assigning an annotation object

Post by Loïc » Mon Dec 30, 2013 9:11 pm

Well... thank you for the solution :)

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest