If you are outputting your form to a PDF and you also have an InkEdit that has text without any spaces like "fffffffff" and it wraps to the next line, then the PDF generated will not automatically insert carriage returns and the text will go off the bounds of the inkEdit and overlap other parts of the form.


As a workaround here is some example code that checks the width of the inkEdit control and inserts carriage returns in appropriate places so the PDF output looks correct. It is possible that extra if conditionals may have to be added if the string in the inkEdit is too long and would require more than three carriage returns for it to fit properly.


 

Public Sub CheckWidth(ByVal textField As InkEdit, ByVal maxWidth As int16)

	' get the size of the text
	Dim textSize As System.Drawing.Size = TextRenderer.MeasureText(textField.Value, textField.Font)

	If (Not textField.Value.Contains(" ")) And (textSize.Width > maxWidth) Then
		Dim ratio As Double = Double.Parse(textSize.Width) / maxWidth
		Dim splits As int16 = Math.Ceiling(ratio)
		
		Dim charLength As int16 = textField.Value.Length
		Dim lineLength As Integer = Math.Truncate(Double.Parse(charLength) / splits)

		If ( splits == 2 ) Then
   			' split it into two pieces 
			Dim textPart1 As String = textField.Value.Substring(0,lineLength) 
			Dim textPart2 As String = textField.Value.Substring(lineLength,textField.Value.Length - lineLength) 
			' put in a carriage return
			textField.Value = textPart1 & vbCrLf & textPart2
		Elseif ( splits == 3 ) Then
			' split it into three pieces 
			Dim textPart1 As String = textField.Value.Substring(0,lineLength)
			Dim textPart2 As String = textField.Value.Substring(lineLength, 2*lineLength)
			Dim textPart3 As String = textField.Value.Substring(2*lineLength,textField.Value.Length - 2*lineLength)

			' put in a carriage return
			textField.Value = textPart1 & vbCrLf & textPart2 & vbCrLf & textPart3
		Elseif ( splits == 4 ) Then
			' split it into four pieces 
			Dim textPart1 As String = textField.Value.Substring(0,lineLength)
			Dim textPart2 As String = textField.Value.Substring(lineLength, 2*lineLength)
			Dim textPart3 As String = textField.Value.Substring(2*lineLength, 3*lineLength)
			Dim textPart4 As String = textField.Value.Substring(3*lineLength,textField.Value.Length - 3*lineLength)

			' put in a carriage return
			textField.Value = textPart1 & vbCrLf & textPart2 & vbCrLf & textPart3 & vbCrLf & textPart4

		'' Extra ElseIf conditionals could be added here if string is too long
		End If
	End If
End Sub

   




To call that function, CheckWidth(), utilize something similar to this so it only reformats the inkEdit for the PDF then sets it back.

'store the value in the field so you can restore it later
Dim tempData As String = textField.Value
 
'send the field you will be checking
'set the max width you will allow in this field
'this number will need to be modified for your form field
CheckWidth(_InkEdit, 1000)

'run the PDF Export function - whatever you may call it
GeneratePDF()

'now set the original value back
textField.Value = tempData