2014-03-13 73 views
1

我需要合併2段,第一個是點的序列,第二個是,我想上的點寫的文字:如何用虛線劃線文字?

 Paragraph pdots1 = new Paragraph("......................................................................................................................",font10); 
     Paragraph pnote= new Paragraph("Some text on the dots", font10); 

我試着玩: pnote.setExtraParagraphSpace(-15 ); 但是,這下一段落。我也試過這個:itext positioning text absolutely 並且工作正常,但只有當我的pdf大小是固定的。所以不要解決我的問題。

回答

1

當您需要虛線時,使用帶點的字符串不是一個好主意。最好使用使用DottedLineSeparator類創建的虛線。例如參見UnderlineWithDottedLine的例子。

Paragraph p = new Paragraph("This line will be underlined with a dotted line."); 
DottedLineSeparator dottedline = new DottedLineSeparator(); 
dottedline.setOffset(-2); 
dottedline.setGap(2f); 
p.add(dottedline); 
document.add(p); 

在此示例中(參見underline_dotted.pdf爲結果),I添加行2分段落(使用setOffset()方法)的基線下和我定義的2個點的點間的間隙(使用setGap()方法)。