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.

Sun Dec 28, 2014 7:01 am

How do you convert a aspx webpage in asp.net to a pdf? I know you can link a url and convert it but how do you do an default.aspx page in spire.pdf?

rbellehu
 
Posts: 2
Joined: Sun Dec 28, 2014 6:56 am

Mon Dec 29, 2014 8:26 am

Dear rbellehu,

Sorry for the delay reply.

For your requirement, please refer to the code below:
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
   PdfDocument pdf = new PdfDocument();
   StringWriter sw = new StringWriter();
   HtmlTextWriter htw = new HtmlTextWriter(sw);
   this.RenderControl(htw);
   //string sourceCode = sw.ToString();
   string url=Request.Url.AbsoluteUri;
   Thread thread = new Thread(() =>
   {
      PdfPageSettings settings = new PdfPageSettings();
      PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();
      pdf.LoadFromHTML(url, false, true, true, settings, format);
      //pdf.LoadFromHTML(Request.Url.AbsoluteUri, false, true, true);
   });
   pdf.SaveToHttpResponse("4159.pdf", Response, HttpReadType.Save);
}
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Dec 30, 2014 8:55 am

Dear rbellehu,

Have you tried the code snippet to convert an aspx page to pdf? Did it work?

Looking forward to your response.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Dec 31, 2014 1:41 pm

Hello Burning,
Tried the code but it generates a blank pdf. I think the problem with going through the URL is the Forms Authentication Membership. It does not appear to be allowing the program in to the site to create the page.
Best Regards,
Ron

rbellehu
 
Posts: 2
Joined: Sun Dec 28, 2014 6:56 am

Thu Jan 01, 2015 6:55 am

Hello,

Sorry that currently our product doesn't support the feature to convert an aspx page needs to be authenticated to pdf.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.PDF