我发现这段代码将文本放在页面的特定位置。
ColumnText ct = new ColumnText(cb);
Phrase myText = new Phrase("TEST paragraphnNewline");
ct.SetSimpleColumn(myText, 34, 750, 580, 317, 15, Element.ALIGN_LEFT);
ct.Go();
现在我希望在一系列文本的forloop中这样做。我有
columnText ct = new ColumnText(cb)
Phrase myText; int x = 34; int y = 750;
for(int i = 0; i<5; i++){
myText = new Phrase("TEST paragraphnNewline");
ct.SetSimpleColumn(myText, x, y, 580, 317, 15, Element.ALIGN_LEFT);
ct.Go();
x += 10;
y+= 12;
}
但是这给了我一个错误,因为文档无法创建。
我该怎么做呢?
尝试将对象创建移动到循环中:
//Declare ct
columnText ct;
Phrase myText; int x = 34; int y = 750;
for(int i = 0; i<5; i++){
//Instantiate ct
ct = new ColumnText(cb);
myText = new Phrase("TEST paragraphnNewline");
ct.SetSimpleColumn(myText, 34, 750, 580, 317, 15, Element.ALIGN_LEFT);
ct.Go();
x += 10;
y += 12;
}