Hi,
We have recently brought the complete suite of Aspose DLL for .net.
We are converting HTML to PDF using aspose PDF with following code. Special characters are getting trucated in this coversion from HTML to PDF. Issue here is that HTML are getting build on run time from data from database and we could not parse either data from database or HTML content to filter or handle these special characters as it would degrade performance of overall operation.
We are using UTF8 encoding for generating HTML.
Content as visible in HTML: -<$2 million Referrals
Content as visible in PDF: -
Please suggest how we could resolve this issue for scenario mentioned.
private void ExportToPDF(string strTemplateRead)
{
try
{
//Encoding encoding = Encoding.GetEncoding(65001);
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
// Read the contents of HTML file into StreamReader object
StreamReader r = File.OpenText(strTemplateRead);
//StreamReader r = new StreamReader(Response.GetResponseStream(), encoding);
pdf.HtmlInfo.CharSet = "UTF-8";
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
//Add the text paragraphs containing HTML text to the section
section.Paragraphs.Add(text2);
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.ContentEncoding = Encoding.Default;
Response.AppendHeader("Content-Disposition", "attachment");
pdf.Save("NewDoc.pdf", Apdf.SaveType.OpenInBrowser, Response);
r.Close();
}
#region Exceptions
catch (Exception notsupex)
{
new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Not Supported Exception :", notsupex).WriteLog(HttpContext.Current.User.Identity.Name);
}
#endregion
}
Regards,
Dinesh