我有類似的問題,但由於這個問題答案系列我得到了Mr.Harjinder所述的解決方案,但這裏有一個提示,面對同樣的問題創建PDF文件後保留軌道所需的寬度和最後當你有水平滾動的軌道下面創建您的文檔的例子
列表和與水平滾動條的PDF
public class Sample {
public static void main(String[] args) {
try {
float indentationLeft = 20f;
float indentationLeftTemp = 20f;
List prtLst = new List(List.UNORDERED);
prtLst.setListSymbol("\u2022");
prtLst.add("P1");
prtLst.setListSymbol("+");
prtLst.add("P2");
prtLst.setListSymbol("\u2022");
List prevList= prtLst;
for(int i=0;i<500;i++){
List chldLst2 = new List(List.UNORDERED);
chldLst2.setIndentationLeft(indentationLeft);
indentationLeftTemp+=20f;
chldLst2.setListSymbol("\u2022");
chldLst2.add("YY"+i);
prevList.add(chldLst2);
prevList=chldLst2;
}
prtLst.add("P3");
Document d = null;
if(indentationLeftTemp>400f){
Rectangle pageSize=new Rectangle(indentationLeftTemp+200f,indentationLeftTemp+200f);
d = new Document(pageSize);
}else{
d = new Document();
}
PdfWriter.getInstance(d, new FileOutputStream("D:/test.pdf"));
d.open();
d.add(prtLst);d.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
當要求把一個水平滾動在PDF上滾動瀏覽欄,將PDF視爲數字紙:您將如何滾動瀏覽她的欄目打印紙張?問問自己:使用傳統紙張時甚至有可能嗎? ;-) –
感謝Bruno Lowagie的回覆。 – Harjinder