0

vb.netで可能であればお願いします

4

2 に答える 2

4

Rectangleオブジェクトを作成し、そのBackgroundColorプロパティを設定できます。yourRectangleを使用して を初期化しますDocument

SourceForge の iTextSharp サイトにあるこのチュートリアルでは、これについて説明しています (PageSize セクションを参照)。

同じサイトには、何をする必要があるかを示すコード サンプルがあります。(「ステップ 1」を参照)。サンプルは C# で書かれており、あなたが VB.NET でそれを望んでいることはわかっているので、developerfusion サイトでC# から VB.NET へのコンバーターを実行しました。今のマシンからの結果をテストコンパイルすることはできませんが、コードは妥当に見えます:

Imports System
Imports System.IO

Imports iTextSharp.text
Imports iTextSharp.text.pdf

Public Class Chap0102

    Public Shared Sub Main()
        Console.WriteLine("Chapter 1 example 2: PageSize")

        ' step 1: creation of a document-object
        Dim pageSize As New Rectangle(144, 720)
        pageSize.BackgroundColor = New Color(&Hff, &Hff, &Hde)
        Dim document As New Document(pageSize)

        Try

            ' step 2:
            ' we create a writer that listens to the document
            ' and directs a PDF-stream to a file

            PdfWriter.getInstance(document, New FileStream("Chap0102.pdf", FileMode.Create))

            ' step 3: we open the document
            document.Open()

            ' step 4: we Add some paragraphs to the document
            For i As Integer = 0 To 4
                document.Add(New Paragraph("Hello World"))

            Next
        Catch de As DocumentException
            Console.[Error].WriteLine(de.Message)
        Catch ioe As IOException
            Console.[Error].WriteLine(ioe.Message)
        End Try

        ' step 5: we close the document
        document.Close()
    End Sub
End Class

試してみる。

于 2009-12-18T06:56:49.873 に答える
1

colorは名前空間に存在せず、エラーはコードにあります:

pageSize.BackgroundColor = New **Color**(&Hff, &Hff, &Hde) 
于 2010-07-18T06:29:41.810 に答える