Using System;
Using System. collections;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. Web;
Using System. Web. sessionstate;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. htmlcontrols;
Using Itextsharp. text;
Using Itextsharp.text.pdf;
Using System. IO;
Namespace Itext
{
/**/ /// <Summary>
///Abstract description of chap0105.
/// </Summary>
Public Class Chap0105: system. Web. UI. Page
{
Private Void Page_load ( Object Sender, system. eventargs E)
{
// Step 1
// Need to write to memory first due to IE wanting
// To know the length of the PDF beforehand
Memorystream m = New Memorystream ();
Document document = New Document ();
Try
{
// Step 2: we set the contenttype and create an instance of the writer
Response. contenttype = " Application/PDF " ;
Using writer. getinstance (document, M );
// Step 3
Document. open ();
// Step 4
Document. Add ( New Paragraph (datetime. Now. tostring ()));
}
Catch (Effecentexception ex)
{
Console. Error. writeline (ex. stacktrace );
Console. Error. writeline (ex. Message );
}
// Step 5: Close document
Document. Close ();
// Step 6: Write PDF bytes to outputstream
Response. outputstream. Write (M. getbuffer (), 0 , M. getbuffer (). Length );
Response. outputstream. Flush ();
Response. outputstream. Close ();
}
Generated by the web Form DesignerCode # Region Code generated by web Form Designer
Override Protected Void Oninit (eventargs E)
{< br> //
// codegen: This call is ASP.. NET web form designer.
//
initializecomponent ();
base . oninit (E);
}
/**/ /// <Summary>
///The designer supports the required methods-do not use the code editor to modify
///The content of this method.
/// </Summary>
Private Void Initializecomponent ()
{
This. Load+ = NewSystem. eventhandler (This. Page_load );
}
# Endregion
}
}