Free Support Forum - aspose.com

Convert Aspx to PDF - pdf.BindHTML When Is The Rewrited Version Coming Out?

I tried the following code sample I found in the documentation and found that the "pdf.BindHTML" part would give me the following error message:

"'Aspose.Pdf.Pdf' does not contain a definition for 'BindHTML' and no extension method 'BindHTML' accepting a first argument of type 'Aspose.Pdf.Pdf' could be found (are you missing a using directive or an assembly reference?)" message.

But then I found a link dated 12-18-2009 that basically stated that you guys are rewriting this as you had lots of problems and technical difficulties (http://www.html-to-pdf.net ) that does the same thing....

Convert Aspx to PDF

[C#]

pdf = new Aspose.Pdf.Pdf();

string surl=this.Request.Url.ToString();

WebClient webClient = new WebClient();

byte[] myDataBuffer = webClient.DownloadData(surl);

MemoryStream postStream=new MemoryStream (myDataBuffer);

pdf.BindHTML(postStream);

pdf.Save(@"c:\test.pdf");

Hello Darlene,

Thanks for considering Aspose.

I'm afraid we don't have any definite dates by which this feature will become available. As a workaround for converting HTML pages into PDF format, please try using the following approach HTML to PDF using InLineHTML

In case you encounter any issue or you've any further query, please feel free to contact.

We apologize for your inconvenience.

Hi,


I am using .net 6.3 tool for pdf generation. But the i am getting error The best overloaded method match for ‘Aspose.Pdf.Generator.Pdf.BindHTML(string)’ has some invalid arguments.

the following is the code

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

using (StreamWriter sw = new StreamWriter(x2FormId + “.html”))
{
sw.Write(GetWebContextFromURL(url));
}

// create an instance of PDF class

WebClient webClient = new WebClient();
byte[] myDataBuffer = webClient.DownloadData (“http://www.google.com”);

using (MemoryStream memStream = new MemoryStream(myDataBuffer))
{
pdf.HtmlInfo.ImgUrl = @“http://www.google.com”;
pdf.BindHTML(memStream);
// save the resultant PDF file
pdf.Save(@“c:\HTML_to_PDF.pdf”);
}

An early reply with solution is highly appreciated.

Thanks,
Sai

Hi Sai,

Thank you for the sample code. I tried using your code to test your issue but due to missing variable values and methods, I was unable to replicate the scenario at my end. Please create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

Thanks & Regards,

Hi Sai,

Thanks for your interest in our products. As far as I can understand, the problem is occurring because you are passing MemoryStream object (memStream) to BindHTML method. Please note that BindHTML method only accepts string as an argument. Please first convert the contents of MemorStream object to string format and then pass them to BindHTML method. If you please take a look over the code snippet shared over following link, you will be able to notice the code for converting contents of live web page into PDF format. In case you still face any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

How to – Convert HTML to PDF using InLineHTML approach