Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

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: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF