VB.NET: Online Guide
File: Create, Load a PDF File
File: Create, Load a PDF File
Home ›› XDoc.PDF ›› VB.NET PDF: Create and Load PDF

VB.NET PDF - PDF Creating Using VB.NET

How to Create a PDF using VB.NET Codes in a .NET Imaging Project

VB.NET PDF Creation and Loading Overview

Creating a PDF document is a good way to share your ideas because you can make sure that the PDF file cannot be altered without authorization or leaving footprint. If your application is in need of generating a PDF document for processing and editing, you can choose this RasterEdge PDF file creator for Visual Basic .NET. This library control makes PDF file generating a piece of cake, as it can be easily integrated into many MS Visual Studio .NET applications to create PDF with just a few VB.NET codings. By using Public Sub RasterEdgePdfCreator(), high quality PDF document creation can be achieved easily.

To get this RasterEdge PDF document file creator library, you can download the RasterEdge .NET Image SDK and find the PDF processing component DLL in the Bin folder. We have also provided you with a demo project, which you can find in the Imaging Demo directory, with a file name RasterEdge.Imaging.Demo.PDF.

VB.NET: Create a New PDF Document with One Blank Page

In VB.NET class programming, you can use specific APIs to create PDF file. And the PDF document can contain one empty page or multiple empty pages. The following example will tell you how to create a PDF document with 2 empty pages.

Dim outputFile As String = Program.RootPath + "\\" + "output.pdf"

' Create a new PDF Document object with 2 blank pages
Dim doc As PDFDocument = PDFDocument.Create(2)

' Save the new created PDF document into file

VB.NET: Load PDF Document from Existing PDF File

You may also load or create a PDF document object from existing PDF file in VB.NET.

' Load from a file
Dim inputFilePath1 As String = Program.RootPath + "\\" + "1.pdf"
Dim doc1 As PDFDocument = New PDFDocument(inputFilePath1)
If IsNothing(doc1) Then
    Throw New Exception("fail to load the file")
End If
' ...

VB.NET: Load PDF from Stream Object

By using this demo code, PDF document can be loaded from a stream object in VB.NET programming.

' Load from a stream
Dim inputFilePath2 As String = Program.RootPath + "\\" + "2.pdf"
Dim fileStream As FileStream = File.Open(inputFilePath2, FileMode.Open, FileAccess.Read)
Dim doc2 As PDFDocument = New PDFDocument(fileStream)
If IsNothing(doc2) Then
    Throw New Exception("fail to load PDF document from the stream")
End If
' ...