Answer the question
In order to leave comments, you need to log in
C# (VS 2010) Cyrillic in pdf document properties
Hello!
I'm trying to change the metadata in a pdf document like this:
using PdfSharp;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
...
PdfDocument document = PdfReader.Open(selectedFullPathFile);
document.Info.Author = "Суслик";
document.Save(selectedFullPathFile);
Answer the question
In order to leave comments, you need to log in
I did overcome this problem
. Here is my bike:
class Program
{
static string unicodePrefix = new string(new char[] { '\xFE', '\xFF' });
static string EncodePdfInfoString(string s)
{
byte[] originalByteString = Encoding.Unicode.GetBytes(s);
byte b; //swap pairs
for (var i = 0; i < originalByteString.Length; i += 2)
{
b = originalByteString[i];
originalByteString[i] = originalByteString[i + 1];
originalByteString[i + 1] = b;
}
return unicodePrefix + Encoding.ASCII.GetString(originalByteString);
}
void SomeWork()
{
...
document.Info.Author = EncodePdfInfoString("Суслик");
document.Save(selectedFullPathFile);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question