PdfBox-Android
PdfBox-Android copied to clipboard
Question: PDTextField value with line break "\n"
Hi, I've been generating PDFs using user input and some of the text input allows for line breaks that span multiple lines. I set these strings using PDTextField.setValue()
and a typical multiline string would look like this:
"This is a test string\nThis is a new line\nAnd another"
Problem is, after setting a string with line breaks and generating the PDF, this causes the lines to combine and overlap one another rather than separating to a separate line below (see pic). Does anyone know of a way to set strings with line breaks and have them reflect in a PDF text field?

Here the full code of how I set the value:
PDField treeNode;
try {
treeNode = acroForm.getField(textFieldName);
if (treeNode instanceof PDTextField) {
PDTextField textField = ((PDTextField) treeNode)
textField.setMultiline(true);
textField.setValue(text);
} else {
throw new IOException();
}
} catch (IOException ignored) {
}
hi guys, any news about that one? we have the same issue here and tried a few workarounds with no luck.
regards from sunny Vienna -Eduard