Home » c# » c# – Unicodes ℠, Ⓤ is showing as ?,? while creating pdf, word files using ZIP Entry

c# – Unicodes ℠, Ⓤ is showing as ?,? while creating pdf, word files using ZIP Entry

Posted by: admin February 21, 2020 Leave a comment

Questions:

I have requirement to create word, pdf files with special characters and my content contains Unicodes ℠, Ⓤ. after creating pdf and word file using zip entries the values are created as ?,? instead of origional values,

Converting xml into bytes array and am using those bytes to create word, pdf file. My c# code as follows,

Below code am using for xml string to bytes array conversion:

MemoryStream _MyMemoryStream = new MemoryStream();
PdfReader reader = new PdfReader(myTemplate);
PdfStamper stamper = new PdfStamper(reader, _MyMemoryStream, '
MemoryStream _MyMemoryStream = new MemoryStream();
PdfReader reader = new PdfReader(myTemplate);
PdfStamper stamper = new PdfStamper(reader, _MyMemoryStream, '\0', true);
AcroFields form = stamper.AcroFields;
XfaForm xfa = form.Xfa;
MemoryStream _ms = new MemoryStream(Encoding.UTF8.GetBytes(xmlStringData));
xfa.FillXfaForm(_ms);
stamper.Close();
CreateFile(_MyMemoryStream.ToArray());
', true); AcroFields form = stamper.AcroFields; XfaForm xfa = form.Xfa; MemoryStream _ms = new MemoryStream(Encoding.UTF8.GetBytes(xmlStringData)); xfa.FillXfaForm(_ms); stamper.Close(); CreateFile(_MyMemoryStream.ToArray());

with

CreateFile(bytes[] bytes)
{
    ZipOutputStream ZIPSTREAM = default(ZipOutputStream);
    ZipEntry ZIPENTRY = default(ZipEntry);
    ZIPENTRY = new ZipEntry("Test.Pdf");
    ZIPSTREAM.PutNextEntry(ZIPENTRY);
    ZIPSTREAM.Write(bytes, 0, _File.Value.Length);
}

Some one can help me.

I have tried belwo one also, but this also giving same result,

foreach (var item in Files)
{
    System.IO.File.WriteAllBytes(@"D:\Data\Details.pdf", item.Value);
}
How to&Answers: