I am adding page numbers to a pdf file,
It works correctly with english, but when I try to add hebrew text it ommits those letters.
I assume the problem is with the encoding to base64, how do I solve this?
Code Example
byte[] myBinary = File.ReadAllBytes(path);
using (var reader = new PdfReader(myBinary))
{
using (var ms = new MemoryStream())
{
using (var stamper = new PdfStamper(reader, ms))
{
int PageCount = reader.NumberOfPages;
for (int i = 1; i <= PageCount; i++)
{
ColumnText.ShowTextAligned(stamper.GetUnderContent(i),
Element.ALIGN_CENTER, new Phrase(String.Format("{0} מתוך {1}", i, PageCount)), 297f, 15f, 0);
}
}
myBinary = ms.ToArray();
}
}
string base64EncodedPDF = System.Convert.ToBase64String(myBinary);
return base64EncodedPDF;
In the front all I do is download the file.
$scope.open_letter = function (letter) {
var _letter = myService.PrintLetter().then(function (data) {
var pdfAsDataUri = "data:application/pdf;base64," + data.data;
var a = document.createElement("a");
a.href = pdfAsDataUri;
a.download = "מכתב" + ".pdf";
a.click();
});
}
The reason I am asking this question is because in English it works perfectly, but it just ommits the Hebrew letters, which is interesting- I would assume it would replace it with weird characters.