How to set the background color of a PDF document using iTextSharp

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

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) 
     '// pageSize.BackgroundColor.BackgroundColor = BaseColor.WHITE
        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.

Advertisements

What are browser hijackers?

If you are one of the millions of people who have suffered a browser hijacking, you likely know it, and you clearly remember what you were doing when it happened. The best known form of browser hijacking is when a sudden flood of pop-ups, many of them obscene, explode over your screen and you are forced to use the CTRL-ATL-DEL sequence to close your browser and regain control of your computer.

Continue reading “What are browser hijackers?”

How to use Telnet

Most of you only know that TelNet is a Port ( Port 23 ) or that TelNet is a Remote Control Tool. Remote Control means in this aspect that you as Client can get a Connection to for example a TelNet Server and then you can write Commands in a derivative of a Shell and this commands are executed only on this server not on your machine. But I want to show all you guys how to use this simple Remote Control Tool in several ways, because this simpleness is brilliant.  Continue reading “How to use Telnet”

Assembly Language: Video Character Interface

This section has a set of code examples for writing character data to a PC in 80 character by 25 line mode. The first routine will check the video mode, and if it is a standard mode, the code returns with a no carry condition and starts using the standard video BIOS routines to perform the requested functions. These routines provide many code entry points where other programs may call in. Before using any of the video routines, the program must call the reset_video routine to initialize and make ready the other video calls. Some of the video display routines will respond to video display escape codes. Most of the escape codes deal with standard cursor control functions. There is an example of table selection jumping code.

Most computers use a raster graphics video system. The data is sent to the monitor as rows from left to right that are arranged from top to bottom. The first data bit sent goes to the upper left corner and the last data bit in a frame goes to the lower right corner. When addressing video RAM, the memory may be divided into rows that can be divided into columns. A fundamental understanding of this system is necessary when translating a row and column position into the actual video RAM address for a character or pixel location.

Continue reading “Assembly Language: Video Character Interface”