views:

414

answers:

2

in vb.net please if possible

+2  A: 

You can create a Rectangle object and set its BackgroundColor property. Use your Rectangle to initialize your Document.

This tutorial on the iTextSharp site on SourceForge describes this (see the PageSize section).

The same site has a code sample that demonstrates what you need to do. (see 'step 1'). The sample is in C# and I know you want it in VB.NET so I ran it through the C# to VB.NET converter on the developerfusion site. I can't test compile the results from the machine I'm not now, but the code looks reasonable:

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

Give it a try.

Jay Riggs
A: 

hi color not exist in namespace and error is in code.

pageSize.BackgroundColor = New Color(&Hff, &Hff, &Hde)

Sarandy hasan