PdfName baseFont = dict.GetAsName(PdfName.BASEFONT); if (baseFont.GetBytes()[7] == '+') { string rename = baseFont.ToString().Substring(8); string temp = baseFont.ToString().Replace(rename, "Changed" + cnt).Replace("/", ""); baseFont = new PdfName(temp); dict.Put(PdfName.BASEFONT, baseFont); cnt++; } PdfDictionary fontDescriptor = dict.GetAsDict(PdfName.FONTDESCRIPTOR); PdfDictionary Encoding = dict.GetAsDict(PdfName.ENCODING); if (fontDescriptor == null) return; fontDescriptor.Put(PdfName.FONTNAME, baseFont); PRStream stream = (PRStream)fontDescriptor.GetAsStream(PdfName.FONTFILE3); byte[] data = PdfReader.GetStreamBytes(stream); var str = System.Text.Encoding.Default.GetString(data); byte[] myByte = System.Text.Encoding.Default.GetBytes(str.Replace("OldName", "NewName")); PdfStream NewStream = new PdfStream(myByte); PdfIndirectObject objref = stamper.Writer.AddToBody(NewStream); fontDescriptor.Put(PdfName.FONTFILE3, objref.IndirectReference);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)