VintaSoft Annotation .NET Plug-in Discussions

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

Board index < VintaSoft Imaging < VintaSoft Annotation .NET Plug-in Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

How do I add text to a tiff file.



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.


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:
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


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.


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

Post by Yuri »

You have made a mistake in your cycle, replace:
...
for (int iPageCount = 0; iPageCount < imageAnnotations.Count; iPageCount++)
...
with
...
for (int iPageCount = 0; iPageCount < images.Count; iPageCount++)
...
Sincerely, Yuri


Page 1 from 1: 1