I am using the below code for HTML to PDF using iTextSharp but if there are other language characters those are not visible in pdf
Please tell me the solution for this
<div class="col-sm-2 text-right pull-right">
@using (Html.BeginForm("ExportCommentsAsPdf", "MitigatingControlsAggregate", FormMethod.Post))
{
@Html.AntiForgeryToken()
<input type="hidden" name="GridHtml" />
<input id="exportZone" name="riskIDpdf" type="hidden" value="@Model.RiskID" />
<input id="exportBusinessLine" name="affiliatepdf" type="hidden" value="@Model.Affiliate" />
<input id="exportAffiliate" name="periodStartpdf" type="hidden" value="@Model.PeriodStart" />
<input id="exportFromDate" name="periodEndpdf" type="hidden" value="@Model.PeriodEnd" />
<button id="btnExportasPdf" type="submit" class="btn btn-info btn-submit btn-sm">
<span class="glyphicon glyphicon-export" aria-hidden="true"></span>Export to Pdf
</button>
}
</div>
$("#btnExportasPdf").click(function () {
$("input[name='GridHtml']").val($("#Grid").html());
});
Controller code
[HttpPost, ValidateAntiForgeryToken]
[ValidateInput(false)]
public FileResult ExportCommentsAsPdf(string GridHtml, string riskIdpdf, string affiliatepdf, string periodStartpdf, string periodEndpdf)
{
using (MemoryStream stream = new System.IO.MemoryStream())
{
string fileName = riskIdpdf + "_EP |" + affiliatepdf + " |" + "From : " + periodStartpdf + " |" + " To : " + periodEndpdf + ".pdf";
StringReader sr = new StringReader(GridHtml);
Document pdfDoc = new Document(PageSize.A1, 10f, 10f, 100f, 0f);
BaseFont bfR = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, iTextSharp.text.pdf.BaseFont.CP1257, false);
Font courier = new Font(Font.FontFamily.COURIER, 30, Font.BOLD, BaseColor.ORANGE);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
pdfDoc.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
pdfDoc.Close();
return File(stream.ToArray(), "application/pdf", fileName);
}
}