Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: Unicode hindi text not showing in PDF

$
0
0
Hi,

First - thanks a lot for this wonderful library.

I have run into a peculiar problem. I have developed an ASP.Net application that requires generating PDF from an HTML. This is where your HTML Renderer comes into picture.

The HTML contains Unicode text (Hindi text). For this I am using MS Arial Unicode font. My application runs fine on Win8 desktop (64bit), and generates PDF that properly shows the hindi text. When I deploy the same application on a Windows 2012 server (std) (64bit), the generated PDF shows rectangular boxes in place of hindi text. I have double checked - the server does have MS Arial unicode font installed on it.

In either scenario, I am not storing the PDF to a disk file, instead I am streaming it to the response.

Here is the code fragment I am using to convert HTML to PDF:
using TheArtOfDev.HtmlRenderer.Core.Entities;
using TheArtOfDev.HtmlRenderer.PdfSharp;

PdfGenerateConfig config = new PdfGenerateConfig();
config.PageSize = PdfSharp.PageSize.A4;
config.SetMargins(20);

PdfSharp.Pdf.PdfDocument doc = PdfGenerator.GeneratePdf(html, config, null, null, null);

using (MemoryStream stream = new MemoryStream())
{
   doc.Save(stream, true);
   byte[] pdfBytes = stream.ToArray();
   return pdfBytes;
}
Here is code fragment that I am using to stream the PDF:
string html="some html text";  // GetReportHtml();
byte[] pdfBytes = PdfGenerator.GetPdfBytes(html);

string fileName = "test.pdf";
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

MemoryStream pdfStream = new MemoryStream(pdfBytes);
response.Content = new StreamContent(pdfStream);

response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
response.Content.Headers.ContentDisposition.FileName = fileName;

return response;
Any suggestions/ideas regarding what could be causing this?

Regards,
Vikram

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>