언어를 지정하지 않았으므로 VB.Net에서 대답 하겠지만 필요한 경우 쉽게 C#으로 변환 할 수 있습니다. 첫 번째 질문에 대한
, 단지 해당 유니 코드 코드 포인트 U+00A0
을 사용하여 비 분리 공백을 사용할 수 :
는 VB.Net에서
당신은 그것을 좋아 선언 할 것 :
Dim NBSP As Char = ChrW(&HA0)
그리고 C#으로를 : 필요한 경우
Char NBSP = '\u00a0';
그런 다음 당신은 그것을 연결할 수 있습니다 :
Dim Text2 As String = "This is" & NBSP & "also" & NBSP & "a test"
non-breaking hyphen (U+2011)도 도움이 될 수 있습니다.
두 번째 질문에 대해서는 모든 열의 너비를 설정할 수 있습니다. 그러나 열 너비는 항상 상대 폭으로 설정하면 사용, 그래서 만약 :
T.SetTotalWidth(New Single() {2.0F, 1.0F})
당신이 실제로 말하는 것은 주어진 테이블의 첫 번째 열은 이며, 두 번째 열 배 커야한다는 것입니다 아니요 첫 번째 열은 2 픽셀이고 두 번째 열은 1 픽셀입니다. 이것은 이해하는 것이 매우 중요합니다. 위의 코드는 다음 두 줄과 완전히 동일합니다
T.SetTotalWidth(New Single() {4.0F, 2.0F})
T.SetTotalWidth(New Single() {100.0F, 50.0F})
열 폭은 (내가 정확히 기억 경우) 기본적으로 쓰기 가능한 페이지의 폭의 80 % 테이블의 폭을 기준으로합니다. 당신은 절대 폭이 테이블의 폭을 수정하고자하는 경우 두 가지 속성 설정해야합니다
Option Explicit On
Option Strict On
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
''//File that we will create
Dim OutputFile As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TableTest.pdf")
''//Standard PDF init
Using FS As New FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None)
Using Doc As New Document(PageSize.LETTER)
Using writer = PdfWriter.GetInstance(Doc, FS)
Doc.Open()
''//Create our table with two columns
Dim T As New PdfPTable(2)
''//Set the relative widths of each column
T.SetTotalWidth(New Single() {2.0F, 1.0F})
''//Set the table width
T.TotalWidth = 200.0F
''//Lock the table from trying to expand
T.LockedWidth = True
''//Our non-breaking space character
Dim NBSP As Char = ChrW(&HA0)
''//Normal string
Dim Text1 As String = "This is a test"
''//String with some non-breaking spaces
Dim Text2 As String = "This is" & NBSP & "also" & NBSP & "a test"
''//Add the text to the table
T.AddCell(Text1)
T.AddCell(Text2)
''//Add the table to the document
Doc.Add(T)
Doc.Close()
End Using
End Using
End Using
Me.Close()
End Sub
End Class
: 모두 함께 위의 퍼팅
''//Set the width
T.TotalWidth = 200.0F
''//Lock it from trying to expand
T.LockedWidth = True
을 아래 iTextSharp 5.1.1.0을 표적으로 전체 작업 윈폼 응용 프로그램입니다
답변 해 주셔서 감사합니다. 내가 사용하는 언어는 C#이었고, 코드를 잘 살펴봄으로써 무엇을 할 것인지를 알아낼 수있었습니다. 다시 한번 감사드립니다. – Vinay
문자 NBSP = '\ u00A0'; iTextSharp에서 나를 위해'Â '을 출력합니다. 그것에 대한 수정 프로그램을 찾을 수 없습니다. – James
실제로 이것은 유니 코드 인코딩을 사용하지 않았기 때문인 것으로 보입니다. 하지만 인코딩을 UTF-8로 변경했고 및 이 작동합니다. 어쨌든 +1하십시오. – James