2012-02-10 19 views
0

我需要使用iTextSharp的iTextSharp的列表項不同字體的問題

建議我的PDF顯示這樣的文本,以提高你的學習和記憶

濃縮能力:爲了記住一些你需要學習的東西,只有在你對它有足夠的重視的情況下才能學習,只有在學習的時候你的注意力集中在適當的位置,你纔會保留更長時間的信息。•涉及儘可能多的感官:重寫信息的物理行爲可以幫助將它印在你的大腦上。即使你是一個視覺學習者,也要大聲朗讀你想記住的東西。如果你能有節奏地背誦它,甚至更好。 「

我試圖通過

ListItem firstRecommend = new ListItem(new Chunk("Concentrate:", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD, BaseColor.BLUE))); 
      firstRecommend.Add(new Chunk("In order to remember something you need to learn it. Learning is possible only if you pay enough attention to it. You will retain information for a longer period of time only if you concentrate properly at the time of learning." 
           , new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLUE))); 
      recommendationList.Add(firstRecommend); 

要做到這一點,但沒有奏效整個文本是大膽的,而不是一部分大膽。

這也不起作用

列表項firstRecommend =新的ListItem(新的塊(「集中:」,新的字體(iTextSharp.text.Font.FontFamily.TIMES_ROMAN,11,Font.BOLD,BaseColor.BLUE))); firstRecommend.Chunks.Add(new Chunk(「按順序記住你需要學習的東西它。學習是可能的,只有當你足夠的重視。只有在學習的時間適當集中,您纔會保留更長時間的信息。「 ,new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN,11,Font.NORMAL,BaseColor.BLUE))); recommendationList.Add(firstRecommend);

只有大膽的部分顯示的PDF,因爲我注意到,ListItem.Chunks是隻讀

如何得到這個工作?

回答

3

你可以試試。首先創建一個段落,然後將其添加到列表項中。

請參閱以下代碼。

Chunk c1 = new Chunk("Concentrate:", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD, BaseColor.BLUE))); 
    Chunk c2 = new Chunk("In order to remember something you need to learn it. Learning is possible only if you pay enough attention to it. You will retain information for a longer period of time only if you concentrate properly at the time of learning.", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLUE))); 

    Pharagraph p2 = new Pharagraph(); 
    p2.Add(c1); 
    p2.Add(c2); 

    ListItem firstRecommend = new ListItem(p2);