Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies within .NET ( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Mon Sep 03, 2012 6:47 am

Question: Just write the pdf into browser directly and donot load it from any file, please give a solution.

Solution:
Code: Select all
         //write converted pdf to browser directly
         PdfDocument doc = new PdfDocument();
         Thread thread = new Thread(() =>
        { doc.LoadFromHTML("http://www.google.com/", true, true, true); });
        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
        thread.Join();
        doc.SaveToHttpResponse("sample.pdf", Response, HttpReadType.Open);
        doc.Close();
User avatar

amy.zhao
 
Posts: 2328
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF