Have tried everything to get code below to burn annotation onto single page tif file. Annotation shows up on screen but doesn't save to tif file. Any help would be appreciated.
Using VB.net
Using leadtools.net class library
Dim TcDoc As mydoc.TcDocument
Dim codecs As New RasterCodecs
Dim Counter As Int64
Dim Height As Integer
Dim Width As Integer
Dim text As AnnTextObject
Dim anncodecs As AnnCodecs
Dim tag As RasterTagMetadata
Dim tagId As Integer
Dim i As Int64 = 1
Dim TifFileName As String
AddHandler RasterImageViewer1.PostTransformPaint, New PaintEventHandler(AddressOf RasterImageViewer1_PostTransformPaint)
AddHandler RasterImageViewer1.TransformChanged, New EventHandler(AddressOf RasterImageViewer1_TransformChanged)
With codecs.Options.Pdf.Load 'Some default settings for appearence purposes
.DisplayDepth = 16
.TextAlpha = 4
.XResolution = 300
.YResolution = 300
End With
Try
For Each TcDoc In Me.Documents
For Counter = 1 To TcDoc.PageCount
With Me.RasterImageViewer1
.Image = codecs.Load(TcDoc.SourceFile, 12, CodecsLoadByteOrder.Gray, Counter, Counter)
Application.DoEvents()
.SizeMode = WinForms.RasterViewerSizeMode.Normal
.SizeMode = WinForms.RasterViewerSizeMode.Fit
End With
TifFileName = TcDoc.FileNames.Item(Counter - 1)
codecs.Save(Me.RasterImageViewer1.Image, TifFileName, RasterImageFormat.TifCcittGroup4, 1)
Height = Me.RasterImageViewer1.Image.Height
Width = Me.RasterImageViewer1.Image.Width
Height -= 75
Width -= 400
Me.theContainer = New AnnContainer
Me.theContainer.Bounds = New AnnRectangle(0, 0, RasterImageViewer1.ImageSize.Width, RasterImageViewer1.ImageSize.Height)
Me.theContainer.UnitConverter = New AnnUnitConverter(RasterImageViewer1.ImageDpiX, RasterImageViewer1.ImageDpiY)
text = New AnnTextObject
text.Text = "Confidential Doc"
text.Font = New AnnFont("Arial", New AnnLength(10, AnnUnit.Point), FontStyle.Bold)
text.Bounds = New AnnRectangle(Width, Height, 400, 50, AnnUnit.Pixel)
text.Bounds = New AnnRectangle(Width, Height, 400, 50, AnnUnit.Pixel)
theContainer.Objects.Add(text)
Me.RasterImageViewer1.Invalidate(theContainer.InvalidRectangle)
anncodecs = New AnnCodecs
tag = anncodecs.SaveToTag(Me.theContainer, AnnCodecsTagFormat.Wang) '** Save as Wang compatible
tagId = tag.Id
codecs.WriteTag(TifFileName, 0, tag)
anncodecs.Save(TifFileName, text.Container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite)
codecs.Save(Me.RasterImageViewer1.Image, TifFileName, RasterImageFormat.TifCcittGroup4, 1)
Me.RasterImageViewer1.Invalidate(theContainer.InvalidRectangle)
theContainer.Objects.Clear()
tag = Nothing
Next
i += 1
Next
Catch ex As Exception
MessageBox.Show("Problem adding tags: " & vbCrLf & ex.Message.ToString, "Error: SplitTheFiles", MessageBoxButtons.OK)
Return False
End Try
Return True