Home Features Download Tutorial Version History License PDF Mosaic Blog Source Code
You may use any Web server and any library to handle writing to an output stream. You can use to write binary data to the Response in ASP.NET. (Different libraries may provide different ways for writing out data)
C# :
using PDFMosaic; using System; using System.IO; using System.Web.UI; namespace CreatePDFonWebServer { class CreatePDFonWebServer { static void Main(string[] args) { // Create pdf object PDFDocument document = new PDFDocument(); // Create pdf page PDFPage page = new PDFPage(PDFPaperFormat.A4); // Fill your document with some data PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 16); PDFBrush brush = new PDFSolidBrush(); page.Canvas.DrawString("Hello!", font, brush, 100, 100); document.Pages.Add(page); // Save pdf document to stream MemoryStream pdfStream = new MemoryStream(); document.Save(pdfStream); // Then send it directly to an output stream Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("Content-Disposition", "inline;filename=form.pdf"); Response.AddHeader("Content-Length", pdfStream.Length.ToString()); Response.BinaryWrite(pdfStream.GetBuffer()); Response.End(); } } }
Visial Basic.NET :
Imports PDFMosaic Imports System Imports System.IO Imports System.Web.UI Module CreatePDFonWebServer Sub Main() ' Create pdf object Dim document As New PDFDocument() ' Create pdf page Dim page As New PDFPage(PDFPaperFormat.A4) ' Fill your document with some data Dim font As New PDFFont(PDFStandardFont.Helvetica, 16) Dim brush As New PDFSolidBrush() page.Canvas.DrawString("Hello!", font, brush, 100, 100) document.Pages.Add(page) ' Save pdf document to stream Dim pdfStream As New MemoryStream() document.Save(pdfStream) ' Then send it directly to an output stream Response.Clear() Response.ContentType = "application/pdf" Response.AddHeader("Content-Disposition", "inline;filename=form.pdf") Response.AddHeader("Content-Length", pdfStream.Length.ToString()) Response.BinaryWrite(pdfStream.GetBuffer()) Response.End() System.Windows.Forms.MessageBox.Show("!") End Sub End Module
Home Features Download Tutorial Version History License PDF Mosaic Blog Source Code