I need to locate a multiline text in a pdf document. I found two possibilitis
我需要在pdf文档中找到多行文本。我发现了两个可能性
ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_LEFT, new Phrase(textPhrase), calculatedX,calculatedY, -rotation);
But when I locate the text this way, I just can see the first line and all other lines get cutted.
但是当我以这种方式找到文本时,我只能看到第一行和所有其他行被切割。
TextField tf = new TextField(writer,
new Rectangle(calculatedX, calculatedY, calculatedX + width, calculatedY + height), "");
tf.Text = text;
tf.FontSize = font.Size;
tf.Font = font.BaseFont;
tf.Options = BaseField.MULTILINE | BaseField.READ_ONLY;
tf.TextColor = font.Color;
writer.AddAnnotation(tf.GetTextField());
This works good and I can see all lines but the problem is that i can not set attributes like Bold underline....
这很好,我可以看到所有的行,但问题是我不能设置像Bold下划线的属性....
Can you please help me to find a way, that I can see all lines and set attributes like bold, underline...
你能帮我找到一种方法,我可以看到所有的线条和设置属性,如粗体,下划线......
1 个解决方案
#1
0
I found a way:
我找到了一个方法:
Phrase phrase = new Phrase(text);
phrase.Font.Size = font.Size;
phrase.Font = font;
ColumnText ct = new ColumnText(writer.DirectContent);
ct.SetSimpleColumn(calculatedX, calculatedY, calculatedX + (width), calculatedY + height);
ct.AddElement(phrase);
ct.Go();
#1
0
I found a way:
我找到了一个方法:
Phrase phrase = new Phrase(text);
phrase.Font.Size = font.Size;
phrase.Font = font;
ColumnText ct = new ColumnText(writer.DirectContent);
ct.SetSimpleColumn(calculatedX, calculatedY, calculatedX + (width), calculatedY + height);
ct.AddElement(phrase);
ct.Go();