visual basic pdf examples

Posted by Manjunath Patil on 11:08 PM

How to create PDF document from Visual Basic: "Hello, World!" PDF document
You can download the source code of this example here: pdfdocscout_vb.zip
This guide will teach you how to create simple PDF document using PDFDoc Scout library and Visual Basic

1) Install PDF Scout library on your computer and run Visual Basic. Go to File and click New










The Project Wizard will appear:
2) Select Standard EXE project type and click Open to create a new project.Visual Basic will generate new project called Project1 and will automatically open the main form of the generated project:











3) Click on Form1 surface and Visual Basic will show the code window for Form_Load event:











4) Now you have to add the code that will create PDF document using PDF Scout library.

Here is the source code that you can simply copy and paste into Visual Basic:
Set PDFDoc = CreateObject("PDFDocScout.PDFDocument")
PDFDoc.InitLibrary "demo", "demo"
PDFDoc.OutputFileName = "HelloWorld.pdf"
PDFDoc.AutoOpenGeneratedPDF = true ' automatically open generated PDF document in default PDF viewer application
PDFDoc.BeginDocument
' add text to current page
PDFDoc.Page.AddText "Hello, World!", 100, 100, 15
PDFDoc.EndDocument ' close document
This function will create PDF file "HelloWorld.PDF" pdf document on drive C:\
Hint:
You can simply copy the source code from the snippet above and then paste it in the Visual Basic code editor as it's shown on the screenshot below:
5) Press F5 to run the application (you can also use "Run" "Start" menu command).

Below project in visual basic.net applications please refer

Getting started with PDFDoc Scout library and Visual Basic.NET:
This page contains step-by-step tutorial that will teach you how to create PDF document file in Visual Basic.NET application using PDFDoc Scout library.

1) Install PDFDoc Scout library on your computer and run Microsoft Visual Studio .NET
Go to New menu and click Project... to create new project as shown on screenshot below:










You will see New Project Wizard. Select Windows Application in Visual Basic Projects group:
2) VB.NET will create a new project:
3) To use PDFDoc Scout in Visual Basic.NET we have to add reference to PDFDoc Scout library for current VB.NET project. Select Project in the main menu and click Add Reference command:

Switch to COM tab and find PDFDoc Scout library in the list of available COM objects:

Now click on Select button to add reference to PDFDoc Scout and click OK
4) Now add the code that will create "Hello, World!" PDF document. Double-click Form1 to create Form1_Load event procedure:
The source code editor window will be appear:

5) The code that generate "Hello, World!" PDF document is below. Generated pdf document file will be saved into "c:\HelloWorld.PDF" file. You can simply copy-and-paste this code into your project.



Dim PDFDoc As PDFDocScout.PDFDocument
PDFDoc = New PDFDocScout.PDFDocument ' create
new PDFDoc object

PDFDoc.InitLibrary("demo", "demo") ' init library

PDFDoc.OutputFileName = "c:\HelloWorld.pdf" ' set
output filename for generated PDF document
PDFDoc.AutoOpenGeneratedPDF = true ' set to True
to automatically open generated PDF document in
default PDF viewer application

PDFDoc.BeginDocument ' begin PDF document
generation
' add text to current page
PDFDoc.Page.AddText "Hello, World!", 100, 100, 15
PDFDoc.EndDocument ' close PDF document

Hint:
You can simply copy the source code from the snippet above and paste into Visual Basic.NET code editor window:

0 comments:

Post a Comment