Free Support Forum - aspose.com

Error 500 on PDF.BindHTMLFromUrl

Hi.

When i use this code on aspx page :

string surl = http://mysite.com/default.aspx";

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

pdf.BindHTMLFromUrl(surl);

pdf.Save("Test.pdf", SaveType.OpenInAcrobat, Response);

I have a Server Error 500

My Page has componentart Controls ...

Could you give me some help please.

Cdtl,

Thanks for considering Aspose.

Please try the following codes again.

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
string surl = http://mysite.com/default.aspx";
WebClient webClient = new WebClient();
byte[] myDataBuffer = webClient.DownloadData(surl);
MemoryStream postStream=new MemoryStream (myDataBuffer);
pdf.BindHTML(postStream);
pdf.Save("Test.pdf", SaveType.OpenInAcrobat, Response);

Limitations on current version:

  • Cascading Styles Sheet (CSS) is not supported
  • Complicated Tags are not supported.

Detail information please go to http://www.aspose.com/Wiki/default.aspx/Aspose.Pdf/ConvertingHtmlToPdf.html

I've already tried but it's the same...

The remote server returned an error: (500) Internal Server Error.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

Source Error:

Line 26:             Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
Line 27:             WebClient webClient = new WebClient();
Line 28:             byte[] myDataBuffer = webClient.DownloadData(surl);
Line 29:             MemoryStream  postStream=new MemoryStream (myDataBuffer);
Line 30:             pdf.BindHTML(postStream);

For information, it works very fine with ABCpdf …

Our developers will check this issue and reply to you soon.

For informations :

It works with a page HTMLPage.htm but if i only change the extension to .aspx => Error 500.

These pages work fine when i directly access to them.

Thanks

Can you attach a sample file of .aspx for me to check the exception?

Thanks.

We would check it.

It's a simple architecture :

  • Site Root (with authentication)
    • Page.htm (show only a Hello World message)
    • Page.aspx (show only a Hello World message)
    • ExportPDF.aspx (execute only the BindHTMLFromUrl())

It works for Page.htm but throw Error 500 on Page.aspx

Any ideas ?

Thx

Thanks for considering Aspose.

Our developers are now working hard on this problem but don't get it fixed up yet.

We will give a reply here as long as we get it done.

As your website has been visited by authentication, you should set the Credentials properties of the webClient class. It includes username and password.

You could get the help info from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebclientmemberstopic.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetnetworkcredentialclasstopic.asp.

Thank you and Good Luck!

I am struggling with this same issue and getting nowhere. I have this code (VB). My code dies on the pdf.BindHTML line with a 500 error. We are doing .net 2.0 authentication using the .net login control. Anyone out there please help!

Dim MyURL As Uri
MyURL = Request.Url

Try
Dim client As New System.Net.WebClient()
client.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim myDataBuffer() As Byte = client.DownloadData(MyURL.AbsoluteUri)
Dim postStream As New MemoryStream(myDataBuffer)
pdf.BindHTML(postStream)

pdf.Save(ConfigurationManager.AppSettings(“DataFolderPath”) & “COIPDFTest.pdf”)

Catch ex As Exception
ret = ex.Message

End Try

Hi,

Please have a look at the Pdf.Credentials field. For more information please consult http://www.aspose.com/documentation/file-format-components/aspose.pdf-for-.net-and-java/aspose.pdf.pdf.credentials.html . You can use this with the BindHTMLFromUrl method.

Thanks.