I’m trying to print a string with a line break in it, where this string is fetched from a csv file.
When running the code below, typing in the string with the line break myself, everything works as expected:
import processing.pdf.*;
PFont f;
void setup()
{
size(1000,1000, PDF, "Output.pdf");
background(255);
f = createFont("Arial",16);
}
void draw()
{
Table table;
table = loadTable("Input.csv", "header");
for (int i = 0; i < table.getRowCount(); i = i + 1)
{
textFont(f);
fill(0);
text("First line.\nSecond line.", 100, 100); // I'm typing in the string myself here.
}
exit();
}
However, when running this other piece of code below, fetching the string with the line break from a csv file, the line break instructions, “\n”, is printed and no line break occurs:
import processing.pdf.*;
PFont f;
void setup()
{
size(1000,1000, PDF, "Output.pdf");
background(255);
f = createFont("Arial",16);
}
void draw()
{
Table table;
table = loadTable("Input.csv", "header");
for (int i = 0; i < table.getRowCount(); i = i + 1)
{
textFont(f);
fill(0);
text(table.getString(i,"Column_1"), 100, 100); // I'm fetching the string from the csv file here.
}
exit();
}
This is what the csv file looks like:
"Column_1"
"First line.\nSecond line."