How do I add text to a tiff file.

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
mferlito
Posts: 2
Joined: Tue Jul 05, 2011 11:06 am

How do I add text to a tiff file.

Post by mferlito »

How do I add text to a tiff file.

// create image collection
ImageCollection images = new ImageCollection();
// create annotation controller associated with image collection
AnnotationController annotations = new AnnotationController(images);
// load TIFF file into collection
images.Add(FileName);

// get annotation collection for selected image
AnnotationCollection imageAnnotations = annotations[images.Count - 1];

// create new annotation
TextAnnotation annoTex = new TextAnnotation();
annoTex.BackColor = Color.Black;
annoTex.Text = "Text";
annoTex.Border = true;
annoTex.FontSizeDependsImageResolution = true;
annoTex.Font = new Font("Arial", 72);
annoTex.Location = new PointF(250, 150);
annoTex.Visible = true;
annoTex.ZOrder = 0;

// add new annotation into annotation collection
imageAnnotations.Add(annoTex);

// specify that annotations must be saved with image collection
images.SetSaveAnnotations(true);
images.SaveAndSwitchSource = true;

// save image collection synchronously to new file
images.SaveSync(_saveFilename);

so it does not work
Thanks.
Yuri
Posts: 64
Joined: Wed Jul 23, 2008 2:47 pm

Re: How do I add text to a tiff file.

Post by Yuri »

Hi,

You have not set the size of annotation, so it was 0. Change you annotation creation code like below:

Code: Select all

TextAnnotation annoTex = new TextAnnotation();
annoTex.ForeColor = Color.Black;
annoTex.Text = "Text";
annoTex.Border = true;
annoTex.FontSizeDependsImageResolution = true;
annoTex.Font = new Font("Arial", 24);
annoTex.Location = new PointF(250, 150);
annoTex.Size = new SizeF(200, 100);
annoTex.Visible = true;
annoTex.ZOrder = 0;
Sincerely, Yuri
mferlito
Posts: 2
Joined: Tue Jul 05, 2011 11:06 am

Re: How do I add text to a tiff file.

Post by mferlito »

Thanks.

Now works.

How do I merge ?

ImageCollection images = new ImageCollection();
AnnotationController annotations = new AnnotationController(images);
images.Add(FileName);

AnnotationCollection imageAnnotations = annotations[images.Count - 1];

TextAnnotation annoTex = new TextAnnotation();
annoTex.BackColor = Color.Transparent;
annoTex.Text = "Text";
annoTex.Border = false;
annoTex.FontSizeDependsImageResolution = true;
annoTex.Font = new Font("Arial", 72);
annoTex.Location = new PointF(250, 150);
annoTex.Size = new SizeF(200, 100);
annoTex.Visible = true;
annoTex.ZOrder = 0;

imageAnnotations.Add(annoTex);

images.SetSaveAnnotations(true);
images.SaveAndSwitchSource = true;
annotations.MergeImageCollectionWithAnnotations(imageAnnotations);

images.SaveSync(_saveFilename);

So it does not work.

Thanks.
Yuri
Posts: 64
Joined: Wed Jul 23, 2008 2:47 pm

Re: How do I add text to a tiff file.

Post by Yuri »

You have made a mistake in your cycle, replace:

Code: Select all

...
for (int iPageCount = 0; iPageCount < imageAnnotations.Count; iPageCount++)
...
with

Code: Select all

...
for (int iPageCount = 0; iPageCount < images.Count; iPageCount++)
...
Sincerely, Yuri
Post Reply