Sample.pdf (307.1 KB)
TextField_Created_PDF.pdf (312.5 KB)
Overlapping_Text.png (20.6 KB)
dll_Properties.png (14.9 KB)
I tried using latest aspose.pdf however it did not worked. I have attached all files for your reference.
my code:
Dim absorber As New TextFragmentAbsorber(phrase:="<(?.*?)>>", textSearchOptions:=New TextSearchOptions(True))
pdfdocument.Pages.Accept(absorber)
If absorber.TextFragments.Count > 0 Then
'<<LSONEAMT_BS1>>
Dim InitialWidth As Int32 = 23
Dim SignatureWidth As Int32 = 80
Dim SignatureFieldHeight As Int32 = 13
Dim Offset As Int32 = 1
CreateTokenTable()
Dim formEditor As New Facades.FormEditor(pdfdocument)
'Record the tokens
For Each fragment As TextFragment In absorber.TextFragments
Tokenname = fragment.Text.ToUpper.Replace("<", "").Replace(">", "")
AddTokenDimensions(Facades.FieldType.Text, Tokenname, fragment.Page.Number, fragment, DataUtil.GetInt32(IIf(fragment.Text.ToUpper.Contains("INITIAL"), InitialWidth, SignatureWidth)), SignatureFieldHeight)
Dim isTokenValid = IsValidToken(Tokenname, valToken)
AddTokensToDocTokensTable(isTokenValid, valToken)
Next
For Each fragment As TextFragment In absorber.TextFragments
fragment.Text = String.Empty 'New String(" "c, fragment.Text.Length)
Next
'place tokens
Dim dr() As DataRow
Dim LLX As Int32, LLY As Int32
Dim RowBottom As Int32
For Each Page As Aspose.Pdf.Page In pdfdocument.Pages
dr = dtSignTokens.Select("PageIndex=" & Page.Number, "LLY asc, LLX asc")
If dr IsNot Nothing AndAlso dr.Count > 0 Then
For Each drToken As DataRow In dr
LLX = DataUtil.GetInt32(drToken("LLX"))
LLY = DataUtil.GetInt32(drToken("LLY"))
formEditor.AddField(DataUtil.GetInt32(drToken("FieldType")) _
, DataUtil.GetString(drToken("TokenName")) & "_" & TokenCnt.ToString _
, DataUtil.GetInt32(Page.Number) _
, LLX _
, LLY _
, DataUtil.GetInt32(drToken("URX")) _
, DataUtil.GetInt32(drToken("URY")))
TokenCnt = TokenCnt + 1
Next
End If
Next
formEditor.Save(_filepath)
End If
Private Sub CreateTokenTable()
dtSignTokens = New DataTable
dtSignTokens.Columns.Add(“FieldType”, GetType(Int32))
dtSignTokens.Columns.Add(“TokenName”, GetType(String))
dtSignTokens.Columns.Add(“FieldWidth”, GetType(Int32))
dtSignTokens.Columns.Add(“FieldHeight”, GetType(Int32))
dtSignTokens.Columns.Add(“PageIndex”, GetType(Int32))
dtSignTokens.Columns.Add(“LLX”, GetType(Int32))
dtSignTokens.Columns.Add(“LLY”, GetType(Int32))
dtSignTokens.Columns.Add(“URX”, GetType(Int32))
dtSignTokens.Columns.Add(“URY”, GetType(Int32))
dtSignTokens.AcceptChanges()
End Sub
Private Sub AddTokenDimensions(FldType As Facades.FieldType, TokenName As String, PageIndex As Int32, TF As TextFragment, FieldWidth As Int32, FieldHeight As Int32)
Dim dr As DataRow = dtSignTokens.NewRow
dr("FieldType") = DataUtil.GetInt32(FldType)
dr("TokenName") = TokenName
dr("FieldWidth") = FieldWidth
dr("FieldHeight") = FieldHeight
dr("PageIndex") = PageIndex
dr("LLX") = TF.Rectangle.LLX
dr("LLY") = TF.Rectangle.LLY
dr("URX") = TF.Rectangle.URX
dr("URY") = TF.Rectangle.URY
dtSignTokens.Rows.Add(dr)
dtSignTokens.AcceptChanges()
End Sub