Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am trying to convert a html string which contains the devanagri text to a pdf file using EO.PDF. The font that I am using in my html is named 'k010_0.TTF' While debugging, the html string is created correctly but as soon as the html is convert to html the text changes.
Am I missing anything while adding a new font in PDF.

What I have tried:

The following is my html string:-
HTML
<html>
<head>
    <title></title>
   
    <style type="text/css">
        .style1
        {
            font-family: "Kruti Dev 010";
        }
    </style>
   
</head>
<body>
       <table width="100%">
	<tbody>
		<tr>
		<td class="style1">fsdfsdfsdfsdfdsf</td>
		</tr>
        <tr><td></td></tr>
		<tr>
			
			<td align="center" class="style4"><img src="##Offer_Details.InspirePath##" style="position: static" /></td>
		</tr>
	</tbody>
</table>
</body>
</html>


And the following is my code for calling the EO.Pdf function
ConvertHtml()


C#
public static void HTMLStringToPdf_EO(string strhtml, string fileDisplayName)
        {
            HttpResponse response = HttpContext.Current.Response;
            response.ClearContent();
            response.AddHeader("content-disposition", "attachment; filename=" + fileDisplayName + ".pdf");
            response.ContentType = "application/pdf";

            HtmlToPdfOptions options = new HtmlToPdfOptions();
            if (!String.IsNullOrEmpty(headerText))
                options.HeaderHtmlFormat = headerText;

            if (!String.IsNullOrEmpty(footerText))
                options.FooterHtmlFormat = footerText;

            options.OutputArea = new RectangleF(0.5f, 0.5f, 9f, 12f);
            options.PageSize = PdfPageSizes.B4;

            options.FooterHtmlFormat += "<div style='clear:both;'></div><br/><div style='text-align:left; float:left;'>" + DateTime.Now.ToString("dd/MM/yyyy HH:mm") + "</div>";
            options.FooterHtmlFormat += "<div style='text-align:right; float:right;'>" + "Page {page_number} of {total_pages}" + "</div>";

            HtmlToPdf.ConvertHtml(strhtml, response.OutputStream, options);

            headerText = string.Empty;
            footerText = string.Empty;
        }
Posted
Updated 17-Jan-17 20:56pm
v2
Comments
[no name] 20-Jan-17 3:31am    
Anyway, you could try this method to convert HTML string to PDF file in C#.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900