Products
PDFKit.NET 4.0
Created
11/2/2011
Tags
Generate PDF

The following basic code sample demonstrates how to create new a new PDF document and draw text on it.

C# code sample // Create a text shape to draw text TextShape textShape = new TextShape(50, 750, "Hello World!", Font.HelveticaBold, 16);

// Add the text to the page page.Overlay.Add(textShape);

// write the target document to disk // note that when the target document is written, the source streams // must still be open. for efficiency reasons, all source page content // is extracted as late as possible using (FileStream file = new FileStream(@"....\HelloWorld.pdf", FileMode.Create, FileAccess.Write)) { document.Write(file); } ]]>

VB.NET code sample ' Create a text shape to draw text Dim textShape As New TextShape(50, 750, "Hello World!", Font.HelveticaBold, 16)

' Add the text to the page page.Overlay.Add(textShape)

' write the target document to disk ' note that when the target document is written, the source streams ' must still be open. for efficiency reasons, all source page content ' is extracted as late as possible Using file As New FileStream("....\HelloWorld.pdf", FileMode.Create, FileAccess.Write) document.Write(file) End Using ]]>

Here is the result: