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
The New Project Wizard
will appear. Select
Windows Application
in Visual C# Projects
group:
2) Visual
C# will create a
new empty project:
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:
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):
The source code editor window
will appear:

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, 50, false, false);
// Draw Text
drawing.PlaceText(100, 100, 0, "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:
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:
You can download the source code of this example here: bytescoutpdf_csharp.zip
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead
|