Error while converting webpage to PDf format using aspose.pdf dll

I am trying to evaluate the aspose.pdf dll for our application. While trying to convert an web page into PDF I am facing the following issue. Please find the error details below.

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.ApplicationException: Unknown sub element in Row element. The element name is Row.

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ApplicationException: Unknown sub element in Row element. The element name is Row.]
Aspose.Pdf.Xml.᳚.᳛(Pdf ໞ, Section ᳜, HeaderFooter ᐚ, Table ๪, XmlTextReader ᐌ, ᗲ ᗝ) +1437
Aspose.Pdf.Xml.ᰅ.ᰆ(Pdf ໞ, Section ᖬ, HeaderFooter ᐚ, Cell ᐖ, ᗲ ᨑ, XmlTextReader ᐌ) +7384
Aspose.Pdf.Xml.᯺.᯻(Pdf ᜺, XmlTextReader ᐌ) +7117
Aspose.Pdf.Xml.⁦.Ᾱ(ᾳ Ꮙ, XmlTextReader ᐌ) +9146
Aspose.Pdf.Xml.ᾳ.᾽(XmlTextReader ι) +94
Aspose.Pdf.Xml.ᾳ.ᾼ(XmlDocument ᜺, XslTransform Ά) +131
Aspose.Pdf.Pdf.BindHTML(Stream htmlStream) +116
PExt.Ext.ExtractIntoPDF_Click(Object sender, EventArgs e) +259
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +105
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +51

Can any one help me how to resolve this error?

Hello Sudheer,

Thanks for considering Aspose.

Let me share some details regarding HTML2PDF conversion. This is Beta version of Html2Pdf. Only simple HTML is supported. Please make sure the input HTML file is in correct format.

Can you please share the resource documents and the code snippet that you are using for conversion, so that we can test the issue at our end. We apologize for your inconvenience.

We are trying to extract an MOSS page (contains some status reports) into PDF format. The web page contains images as well. Please let me know will the dll suppport for images or not.

Please find the code snippet below:

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

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

WebClient webClient = new WebClient();

webClient.Credentials = new NetworkCredential("@UserName", "@Password");

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

MemoryStream postStream = new MemoryStream (myDataBuffer);

pf.BindHTML(postStream);

pf.Save(@"E:/PDFExt.pdf");

Hello Sudheer,

In order for us to test the issue, can you please save the MemoryStream into File object and share it so that we can test the conversion at our end.

The easiest way would be to open a file stream and then use:

byte[] data = stream.ToArray();
FileStream fs = new FileStream(newFile, FileMode.CreateNew);
fs.Write(data, 0, data.Length);

That’s relatively inefficient though, as it involves copying the buffer. It’s fine for small streams, but for huge amounts of data you should consider using:

fileStream.Write(memoryStream.GetBuffer(), 0, memoryStream.Position);

(assuming the memory stream is already positioned at the end).

According to your scenario you can use myDataBuffer- instead of data array used in above example. And regarding your query to add Images during PDF conversion, please visit the following link for HTML to PDF using MemoryStream.