- Home
- Testimonials
- Purchase
- Developer Tools
- Desktop Utilities
- Download
- Support
- Blog
- Company
Quick start tutorial: generating PDF document in ASP.NET with Bytescout.PDF (on ASP.NET web-server)
How to create PDF document using Bytescout.PDF library in ASP.NET environment
"Hello, World!" example
"Hello, World!" example
You can download the source code of this example here: bytescoutpdf_asp_net.zip
This page contains step by step tutorial how to create PDF document in ASP.NET using Bytescout.PDF library.
IMPORTANT NOTE: To use Bytescout.PDF library on web-server you have to have additional "Web License"
Bytescout.PDF library is capable of generating of in-memory PDF files so file needn't to be stored as a file on hard drive and can be streamed right into the browser window.
There is a special "GenerateInMemoryFile" property for such purposes. Set this property to TRUE and the library will generate and keep your PDF as in-memory stream without using of any temporary files.
1) Install Bytescout.PDF library on your computer and run Visual Studio.NET
2) Go to File menu and select New Project:

Select ASP.NET Web Application project type and click OK

3) Visual Studio.NET will create new empty ASP.NET project. Double-click on the empty space of the form:

This will open source code editor window on procedure handling Page_Load event. We will place our code for PDF PDF animation generation into this procedure:

4) Use the following code for procedure (you can simply copy and paste this code from this page into ASP.NET source code editor window):
// Create main PDF Doc Engine
PDFDocEngine engine = new PDFDocEngine("", "");
// Add new document
Document document = engine.AddDocument();
// Append new page to the document
Bytescout.PDF.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();
// clear http output
Response.Clear();
// set the content type to PDF
Response.ContentType = "application/pdf";
// add content type header
Response.AddHeader("Content-Type", "application/pdf");
// set the content disposition
Response.AddHeader("Content-Disposition", "inline;filename=HelloWorld.pdf");
// write the buffer with pdf file to the output
document.Save(Response.OutputStream);
Response.End();
5) Now run ASP.NET project using Debug | Start command:

Visual Studio.NET will run ASP.NET project on web-server and you will see Internet Explorer window with generated PDF document:

You can download the source code of this example here: bytescoutpdf_asp_net.zip
Filed in:
PDF SDK for .NET
Tutorials:


