2010-08-02 2 views
0

ITextsharp의 표 셀에 추가 된 목록에 글꼴을 할당하는 방법이 있습니까? 나는 그것이 직설적 일 것임에 틀림 없다라고 확신한다. 그러나 나는 그것을 놓치고있다.ITextSharp, 셀 내의 목록에 글꼴 지정?

Dim tblSignature As New PdfPTable(1) 
     tblSignature.WidthPercentage = 90.0F 

     Dim _baseFont As BaseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED) 

     Dim _bFont As New Font(_baseFont, 4, Font.ITALIC, Color.RED) 

     Dim cell As New PdfPCell(New Phrase(TheItem.Value, _bFont)) 

     TheParagraph.Font = _bFont 


     Dim list As New List(list.UNORDERED, 25.0F) 
     list.SetListSymbol("[ ]") 


     If ListItems.Count > 0 Then 
      For Each ListItem In .ListItems 
       //I have tried adding as chunk/phrase and applying font but no joy 
       //Item not added to cell 
       //list.Add(New Chunk(ListItem, _bFont)) 

       list.Add(ListItem) 
      Next 

      list.IndentationLeft = 5.0F 

      cell.AddElement(list) 
     End If 

     cell.Colspan = 6 
     cell.HorizontalAlignment = 0 
     cell.PaddingBottom = 5.0F 
     cell.PaddingLeft = 5.0F 
     cell.PaddingRight = 5.0F 

     '' add to doc 
     tblSignature.AddCell(cell) 

     TheParagraph.Add(tblSignature) 

누구든지 알고 있습니다. 목록/셀에 맨 위에 설정 한 특정 글꼴이 있도록 어떻게 변경합니까?

건배

답변

5

iTextSharp.text.ListItem 객체는 설정할 수 있습니다 iTextSharp.text.Font 속성이 있습니다.

+0

피 묻은 도대체, 나는 ListItem을 사용하는 대신 문자열을 직접 목록에 적용하고 있습니다. – Israfel

0

새 PdfPCell 또는 새 구와 같은 선언은 iTextSharp.text.List의 add 메소드에서 작동하지 않음에 유의하십시오. 그러나 둘 다 PdfPTable에서 상당히 잘 작동합니다. iTextSharp.text.List를 사용하여 내 소프트웨어의 pdf 파일을 다음과 같은 방법으로 인쇄했습니다.이 기능이 도움이되기를 바랍니다.

이 소프트웨어는 vb.net (Visual Studio 2010 및 Windows 7 플랫폼) 및 iTextSharp 최신 버전으로 개발 된 소프트웨어 중 하나에서 사용되는 프로그램입니다. for pdf print.It은 iTextSharp.text.List의 글꼴 속성을 조정하는 방법을 보여줍니다.

Dim doc1 As New Document() 

     Dim pathpdf As String = "C:/temp" 

     'path = ServerMapPath("PDFs"); 
     PdfWriter.GetInstance(doc1, New FileStream(pathpdf + "/Doc1.pdf", FileMode.Create)) 
     ' Now to begin actually working with the document, open it, , add a new list,and, then close it: 

     doc1.Open() 


Dim fnt1 As Font = FontFactory.GetFont(FontFactory.HELVETICA, 8, iTextSharp.text.Font.NORMAL) 


Dim fnt2 As Font = FontFactory.GetFont(FontFactory.HELVETICA, 14, iTextSharp.text.Font.BOLD) 


Dim fnt3 As Font = FontFactory.GetFont(FontFactory.HELVETICA, 12, iTextSharp.text.Font.NORMAL) 


Dim lst3 As New iTextSharp.text.List() 


lst3.SetListSymbol("") 


'add a list item in bold letters. 

Dim m_DataHeadOnly As String 

m_DataHeadOnly = "This is the itextsharp font setting with list" 

lst3.Add(New iTextSharp.text.ListItem(m_DataHeadOnly, fnt2)) 


doc1.add(lst3) 

doc1.close()