We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose PDF v3.8.0.0 - Input string was not in a correct format

I am trying to use the Aspose PDF v3.8.0.0 component to render html to a pdf document, but it does not seem to work. I am using ASP.NET 3.5. and I am getting an error stating "Input string was not in a correct format.". Please let me know if there are any obvious errors in my code.

Thank you.

Below is my code and the html I am attempting to render:

protected void ExportToPdf_Click(object sender, EventArgs e)
{
StringBuilder stringBuilder = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(stringBuilder))
{
using (HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter))
{
reportListView.RenderControl(htmlTextWriter);
string htmlOutput = stringBuilder.ToString();
Pdf pdf1 = new Pdf();
pdf1.IsLandscape = true;
Section sec1 = pdf1.Sections.Add();
Text text1 = new Text(sec1, htmlOutput);
text1.IsHtmlTagSupported = true;
sec1.Paragraphs.Add(text1);
pdf1.Save(ReportFileName + "_" + DateTime.Now.ToShortDateString() + ".pdf", SaveType.OpenInBrowser, HttpContext.Current.Response);
Response.End();
}
}
}

This is my output that ends up in the htmlOutput variable above to be saved to the document:

United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
United States of America Number Name Code Qualification
Belgium Number Name Code Qualification

Please see the stack trace as well:

at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Single.Parse(String s, NumberStyles style, NumberFormatInfo info)
at System.Single.Parse(String s)
at Aspose.Pdf.Xml.ᑫ.ᑸ(ᘚ ᑶ, Text ԅ, Section ፕ, Cell ᆬ, Paragraph ᑹ, HeaderFooter ፲)
at Aspose.Pdf.Xml.ᑫ.ᑵ(ᘚ ᑶ, Text ԅ, Section ፕ, Cell ᆬ, Paragraph ᑷ)
at Aspose.Pdf.Xml.ᑫ.ᑸ(ᘚ ᑶ, Text ԅ, Section ፕ, Cell ᆬ, Paragraph ᑹ, HeaderFooter ፲)
at Aspose.Pdf.Xml.ᑫ.ᑲ(Pdf ᇌ, Section ፕ, Table Ԋ, Row ዌ, Cell ᆬ, Text ԅ, ᅖ ᅨ, ᎄ ᏼ, Boolean ᏽ)
at Aspose.Pdf.Xml.ᒪ.ᒬ(Pdf ᇌ, Section ፋ, ᅖ ᅨ)
at Aspose.Pdf.Xml.ճ.ጱ(Pdf ᇌ)
at Aspose.Pdf.Xml.ᇆ.ᇋ(૜ ૑, Pdf ᇌ)
at Aspose.Pdf.Pdf.Save(String fileName, SaveType saveType, HttpResponse response)
at Resources_UserControls_Export.ExportToPdf_Click(Object sender, EventArgs e) in c:\WorkingFolders\Code\UserControls\Export.ascx.cs:line 153
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Hi Robert,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have tested the issue, but I am unable to reproduce the problem. Please share the complete project so that we can test the issue at our end.