New Annotation onto the Image Viewer

Discussions about annotation support.
Post Reply
RobertHorn
Posts: 14
Joined: Fri Jan 20, 2012 8:18 am

New Annotation onto the Image Viewer

Post by RobertHorn » Fri Jan 27, 2012 9:56 am

Hi,

I need to add an rectangle annotation to an image (pdf) and allow the user to move it and resize.

I have been through all of the code, and the way that this is done is something like this:

ImageID = oGdPictureImaging.CreateGdPictureImageFromFile(FileName)

Dim oAnnotationManager As New AnnotationManager
oAnnotationManager.InitFromGdPictureImage(ImageID)
ZoneAnnotation = oAnnotationManager.AddRectangleAnnot(Color.Red, Color.Transparent, AnnotationData.Left, AnnotationData.Top, AnnotationData.Width, AnnotationData.Height)
oAnnotationManager.Close()

imageViewer.DisplayFromGdPictureImage(ImageID)

Now the problem I have here is that CreateGdPictureImageFromFile won't open a PDF. It return 0 to the ImageID, which I presume is it's way of telling me to go get stuffed.

But I don't understand why I just can't load the annotation onto the image viewer. The imageviewer has no problem viewing the pdf, but there is only the AddRectangleAnnotInteractive. I don't want this. I want to put the annotation exactly where it was last.

So please let me know how to add an annotation to an image when going through the ImageViewer.DisplayFromFile method. Or how to get the ImageID from Imageviewer without going through the oGdPictureImaging.CreateGdPictureImageFromFile(FileName) which in this case has a problem with pdfs.

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

Re: New Annotation onto the Image Viewer

Post by Loïc » Fri Jan 27, 2012 5:54 pm

Hi,

First an image is an image & a PDF is a PDF.

GdPcitureImaging class can open image.
GdPicturePDF class can open PDF.

Therefore to add annot to a PDF by code and display the PDF with the added annot in a GdViewer object you have to:

- Load the PDF file into a GdPicturePDF object
- Create a new AnnotationManager object and initialize it from the previously created GdPciturePDF object. See: InitFromGdPciturePDF method.
- Add the desired annotation(s) using the AnnotationManager
- DIsplay the PDF to the GdViewer by using the DisplayFromGdPicturePDF() method.

Let me know if you don't understand.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest