When I try and populate a pdf control and apply the Environment.NewLine it’s not adding the carriage return. For example, I want the textbox to include the following format
More Sample Data
I have the following
string testString = “Sample Data” + Environment.Newline + "More Sample Data"
How do I accomplish adding a carriage return so it drops to a new line? Thanks!
<span style=“font-size: 12pt; font-family: “Times New Roman”,“serif”;”>
Thanks for using our products.
In case you need to add new line character when creating a new PDF document, please try using #$NL instead of Environment.Newline. For more information, please visit Replaceable Symbols
In case it does not satisfy your requirements or you have any further query, please feel free to contact. We apologize for your inconvenience.
I’m trying to populate a pdf template. I’m expecting the string fieldValue to display two lines in the pdf document. When I add the “#$NL” it’s getting rendered in the pdf document - no new line is occuring. Should I be using different steps to accomplish this?
String fieldValue = “This is on first line #$NL this on the second line”;
Document pdfDocument = new Document(path);
Form pdfForm = pdfDocument.Form;
TextBoxField field = pdfForm[fieldName] as TextBoxField;
field.Value = fieldValue;
I just wanted to confirm on adding newline in PDF. I tried with #$NL, but it yeilded no result. Please share me if you have found any work-around for this.
Thanks for your using our products.
In order to insert multiline text, first the field property should be set to accept multiline information. In case you need to place a TextField which can accept multiline information, please try using the following code snippet.
Document pdfDocument = new Document("d:/pdftest/source_updated.pdf");
// create a rectangle object to define the region of text field
Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(100, 200, 300,300);
//create a field
TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages,rect);
// specify the namde of form field
textBoxField.Name = "textbox1";
// specify that text field will be multiline
textBoxField.Multiline = true;
// text value to be placed inside text field
textBoxField.Value = "Text Box \n new line data";
//add field to the document
//save modified PDF
In case you need to insert multiline string inside an TextField already present in a PDF form, please try using the following code line to accomplish your requirement.
//modify field value
textBoxField.Value = "First line \n Second line";
In case you still face any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.