Home
We need your feedback!

Bytescout.PDF for .NET


Subscribe to Our Bi-Monthly Newsletter (tips, new releases, specials):
 Subscribe in a reader
 PRODUCTS  |  DOWNLOAD  |  PURCHASE  |  SUPPORT  |  TESTIMONIALS   |  NEWS  | 

Bytescout.PDF library for .NET

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

How to create PDF document using Bytescout.PDF library in ASP.NET environment
"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:
 
New project menu
 
Select ASP.NET Web Application project type and click OK
 
ASP.NET new project wizard
 
3) Visual Studio.NET will create new empty ASP.NET project. Double-click on the empty space of the form:
 
New blank project generated by ASP.NET
 
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:
 
Page load handler procedure generated by ASP.NET IDE
 

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, 50falsefalse);

// Draw Text
drawing.PlaceText(1001000"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:
 
Start project menu
 
Visual Studio.NET will run ASP.NET project on web-server and you will see Internet Explorer window with generated PDF document:
 
PDF document generated by ASP.NET application
 
 
You can download the source code of this example here: bytescoutpdf_asp_net.zip
 

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

"Hello, World!" quick start step-by-step tutorials:

Advanced Examples:

"Hello, World!" quick start step-by-step tutorials:

Advanced Examples:

HOME  |  CONTACT US

Copyright © ByteScout, 2003-2010. Privacy Statement
Microsoft®, Windows®, Windows 2000®, Windows Server®, Windows Vista®, Internet Explorer®, .NET Framework®, ActiveX®, Visual Basic®, Visual C#®, ASP®, ASP.NET®, Excel®, PowerPoint®, are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Adobe®, Flash® and Acrobat® are registered trademarks of Adobe Systems, Incorporated. Mozilla®, Firefox® and the Mozilla and Firefox Logos are registered trademarks of the Mozilla Foundation. Other product names or brandnames used herein are for identification purposes only and might be trademarks or registered trademarks of their respective companies. We disclaim any and all rights to those marks.