Itextsharpを使用しているMVC3 VB.NETアプリケーション。私はpdfファイルを生成するコードセクションを持っていますが、すべてが素晴らしいようですが、私は2色の間のpdfファイルのラインカラーを交互にして、値を見ている人には簡単に従うことができます。フォントサイズに基づいて、行全体の背景色を設定された色に設定する方法はありますか?私はこの中に使用される関数は、以下である:Contentbyteの背景色を設定するitextsharp
For Each _reg_ In _reg
Dim _registrant As reg_info = _reg_
If y_line1 <= 30 Then
doc.NewPage()
_Page = _Page + 1
y_line1 = 670
End If
If y_line1 = 670 Then
cb.BeginText()
cb.SetFontAndSize(BF_Times, 6)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _datePrinted + " " + _timePrinted, 500, 770, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, "Page Number" + " " + _Page, 600, 770, 0)
cb.SetFontAndSize(BF_Times, 8)
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER, _reportHead + " Overrides ", 304, 720, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "First Name", 20, 700, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Last Name", 80, 700, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Last Four", 160, 700, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "Email Address", 300, 700, 0)
cb.EndText()
End If
cb.BeginText()
cb.SetFontAndSize(BF_Times, 8)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _registrant.first_name, 20, y_line1, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _registrant.last_name, 80, y_line1, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _registrant.last_four_social, 160, y_line1, 0)
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, _registrant.email, 300, y_line1, 0)
_total += 1
cb.EndText()
y_line1 = y_line1 - 15
Next
私はちょうどy_line1を使用して、色が灰色又は白色であるべきであるかどうかを決定するために係数を使用して行の背景色を設定することについて考えました。しかし、私はどのように行全体の背景色を設定する方法についてはどこにコードサンプルが見つかりません..任意のアイデア????