This page contains step by step tutorial how to create PDF document in ASP.NET using PDFDoc Scout library.
'Put user code to initialize the page here
Dim PDFDoc
Dim Size As Long
Dim MemoryImage As System.Array
' create new PDFDoc object
PDFDoc = CreateObject("PDFDocScout.PDFDocument")
' initalize library
PDFDoc.InitLibrary("demo", "demo")
' set in-memory mode
PDFDoc.GenerateInMemoryFile = true ' set to True to generate PDF document in memory without any files on disk to output it to end-user to browser
' starts PDF document generation
PDFDoc.BeginDocument ' start PDF document generation
' add text to current page
PDFDoc.Page.AddText "Hello, World!", 100, 100, 15
PDFDoc.EndDocument ' close PDF document generation
' get size of generated in-memory PDF document
Size = PDFDoc.BinaryImageSize
' create new buffer with size equal to generated pdf document file
Dim Buffer(CInt(Size)) As Byte
' get in-memory pdf file as byte stream
MemoryImage = PDFDoc.BinaryImage
' copy byte stream into buffer
Array.Copy(MemoryImage, Buffer, Size)
' 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
Response.BinaryWrite(Buffer)
Response.End()
' set library object instance to Nothing
PDFDoc = Nothing
No comments:
Post a Comment