Finally I solved this changing in PdfSharp\Pdf\IO\Lexer.cs, in function ScanHexadecimalString() this:
Code:
ScanNextChar();
while (true)
{
MoveToNonWhiteSpace();
if (this.currChar == '>')
{
ScanNextChar();
break;
}
if (char.IsLetterOrDigit(this.currChar))
{
hex[0] = char.ToUpper(this.currChar);
hex[1] = char.ToUpper(this.nextChar);
int ch = int.Parse(new string(hex), NumberStyles.AllowHexSpecifier);
this.token.Append(Convert.ToChar(ch));
ScanNextChar();
ScanNextChar();
}
}
To this:
Code:
ScanNextChar();
MoveToNonWhiteSpace();
while (true)
{
int startPos = this.Position;
if (this.currChar == '>')
{
ScanNextChar();
break;
}
if (char.IsLetterOrDigit(this.currChar))
{
hex[0] = char.ToUpper(this.currChar);
hex[1] = char.ToUpper(this.nextChar);
int ch = int.Parse(new string(hex), NumberStyles.AllowHexSpecifier);
this.token.Append(Convert.ToChar(ch));
ScanNextChar();
ScanNextChar();
}
MoveToNonWhiteSpace();
//Si no es capaz de avanzar detener la ejecuciĆ³n del programa para evitar un bucle infinito
//If it can't follow, stop to avoid an infinite llop
if (this.Position == startPos)
break;
}
Too, I found another problem, a PDF that use the caracter 160 (Chars.NonBreakableSpace) as white space, so I added:
In:
Code:
case Chars.NUL:
case Chars.HT:
case Chars.LF:
case Chars.FF:
case Chars.CR:
case Chars.SP:
ScanNextChar();
break;
This:
Code:
case Chars.NUL:
case Chars.HT:
case Chars.LF:
case Chars.FF:
case Chars.CR:
case Chars.SP:
case Chars.NonBreakableSpace:
ScanNextChar();
break;
I don't know if this is correct.
Regards!