Pdf TextBoxField line break

how do i force a line break in the InteractiveFeatures.Forms.TextBoxField?

Hi,


Thanks for contacting support.

Please try using the following code snippet to accomplish your requirement. For your reference, I have also attached the PDF generated over my end.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document();

pdfDocument.Pages.Add();

//create a field

TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300));

textBoxField.PartialName = "textbox1";

textBoxField.Value = "Text Box \n second line";

textBoxField.Multiline = true;

//textBoxField.Border = new Border(

Border border = new Border(textBoxField);

border.Width = 5;

border.Dash = new Dash(1, 1);

textBoxField.Border = border;

textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);

//add field to the document

pdfDocument.Form.Add(textBoxField, 1);

//save updated document

pdfDocument.Save(“c:/pdftest/MultilineText_output.pdf”);

is there a way to do this with an existing pdf file?

example:

Dim pdf As New Aspose.Pdf.Document(path)

TryCast(pdf .Form(“txtbox1”), InteractiveFeatures.Forms.TextBoxField).Value = "11111111111111111 \n 2222222222222222 "
TryCast(pdf .Form(“txtbox1”), InteractiveFeatures.Forms.TextBoxField).Multiline = True

the above does not work…

Hi,


In order to add multi-line text to form field in existing PDF form, first you need to convert the single line TextField to MultiLine text object. Please try using the following code line to convert form field to multi-line. In case you still face the same issue, please share the resource files so that we can test the scenario at our end. We are sorry for this inconvenience.

[C#]

Aspose.Pdf.Facades.FormEditor formEditor = new Aspose.Pdf.Facades.FormEditor(“PdfForm.pdf”, “PdfForm_updated.pdf”);

formEditor.Single2Multiple(“textField”);

hi, using your example how do i access the text box field value? I am not sure what resource file you’re wanting but below is example of my code:

--------------------------------------------------------------
Dim filepath As String = Request.PhysicalApplicationPath & “tmp” & sFileName
Dim detail As New Aspose.Pdf.Document(filepath)

'populate textfields in detail page template…
Dim dtData As DataTable = db.getuser(1)
Dim dr As DataRow = dtData.Rows(0)

TryCast(detail.Form(“txtDate_P1”), InteractiveFeatures.Forms.TextBoxField).Value = Date.Today.ToString(“MMM d, yyyy”)

TryCast(detail.Form(“textbox1”), InteractiveFeatures.Forms.TextBoxField).Value = "aaaa \n bbbbbb"
TryCast(detail.Form(“textbox1”), InteractiveFeatures.Forms.TextBoxField).Multiline = True



Hi Chris,


The resource file is one which you are loading into Aspose.Pdf.Document object. In order to access TextBox field value, please follow the instructions specified over Get Value from an Individual Field of PDF Document

We are sorry for this delay and inconvenience.