Bytescout.PDF library

Hello, World! example for Bytescout.PDF library and Visual C#: create PDF document

Products Download Purchase Support Contacts
 
Bytescout.PDF library
Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead
Direct Links

 

 

Quick Start with Bytescout.PDF in Visual C#: "Hello, World!" PDF document

You can download the source code of this example here: bytescoutpdf_csharp.zip

 

This page will show how to use Visual C# and Bytescout.PDF library to create "Hello, World!" PDF document (.PDF) 

 
1) Install Bytescout.PDF library on your computer and run Microsoft Visual Studio.NET
 
Go to New menu and click Project... to create new Visual C# project
 
VC# IDE file menu
 
The New Project Wizard will appear. Select Windows Application in Visual C# Projects group:
 
New project wizard in n~ sharp
 
2) Visual C# will create a new empty project:
 
New project generated by C# project wizard
 
3) To use Bytescout.PDF library in Visual C# application we should add the reference to Bytescout.PDF. Select Project in the main menu and then select Add Reference command:
 
Add reference menu in VC#
 
Switch to Browse tab and browse and add "Bytescout.PDF.Demo.dll" (or Bytescout.PDF.dll if you have already purchased full version)
 
4) Double-click on form Form1 to create the Form1_Load procedure (this procedure will be execute on Form1.OnLoad event):
 
Blank form in C# project
 
The source code editor window will appear:
 

Auto generated form load procedure

5) Add Using Bytescout.PDF; in the beginning of the code to use Bytescout.PDF namespace in your Hello, World project

6) The following code snippet generates simple "Hello, World!" PDF document and saves it into "HelloWorld.PDF" file:

            // Create main PDF Doc Engine
            
PDFDocEngine engine = new PDFDocEngine("demo""demo");

            
// Add new document
            
Document document engine.AddDocument();

            
// Append new page to the document
            
Page page document.AddPage(PageSizeType.A3, PageOrientationType.LandScape);

            
// Create new drawing
            
Drawing drawing page.AddDrawing();

            
// Add standard font
            
uint font document.AddFontStandard(StandardFontType.Courier, FontEncodingType.WinAnsi);

            
// Set Active Font
            
drawing.SetActiveFont(font, 50falsefalse);

            
// Draw Text
            
drawing.PlaceText(1001000"Hello World!");

            
// Closing drawing on the page
            
drawing.Close();

            
// Save document
            
document.Save("HelloWorld.pdf");

Hint: you can simply copy the source code from the snippet above and paste into Visual C# source code editor
 
6) Press F5 to run the application (you can also use "Debug" | "Start" menu command) and Visual C#.NET will run the application:
Start project menu
 
The application will create "Hello, World!" PDF animation movie and save it into "HelloWorld.PDF" document file.

You can view generated PDF document using any application that can display PDF document: Adobe Reader:

 
Generated PDF movie
 
You can download the source code of this example here: bytescoutpdf_csharp.zip

See also:

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead
Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials |  
ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement