Exemple #1
0
 /**
   <summary>Gets the character map extracted from the given data.</summary>
   <param name="stream">Character map data.</param>
 */
 public static IDictionary<ByteArray, int> Get(
     bytes::IInputStream stream
     )
 {
     CMapParser parser = new CMapParser(stream);
       return parser.Parse();
 }
Exemple #2
0
 /**
   <summary>Gets the character map extracted from the given data.</summary>
   <param name="stream">Character map data.</param>
 */
 public static IDictionary<ByteArray,int> Get(
   bytes::IInputStream stream
   )
 {
   CMapParser parser = new CMapParser(stream);
   return parser.Parse();
 }
Exemple #3
0
        /**
         * <summary>Loads font information from existing PDF font structure.</summary>
         */
        protected void Load(
            )
        {
            if (BaseDataObject.ContainsKey(PdfName.ToUnicode)) // To-Unicode explicit mapping.
            {
                PdfStream  toUnicodeStream = (PdfStream)BaseDataObject.Resolve(PdfName.ToUnicode);
                CMapParser parser          = new CMapParser(toUnicodeStream.Body);
                codes    = new BiDictionary <ByteArray, int>(parser.Parse());
                symbolic = false;
            }

            OnLoad();

            // Maximum character code length.
            foreach (ByteArray charCode in codes.Keys)
            {
                if (charCode.Data.Length > charCodeMaxLength)
                {
                    charCodeMaxLength = charCode.Data.Length;
                }
            }
            // Missing character substitute.
            if (defaultCode == UndefinedDefaultCode)
            {
                ICollection <int> codePoints = CodePoints;
                if (codePoints.Contains((int)'?'))
                {
                    DefaultCode = '?';
                }
                else if (codePoints.Contains((int)' '))
                {
                    DefaultCode = ' ';
                }
                else
                // PK 2017-03-08 - allow for encoding to fail, which should just result in a "?" or rectangle appearing instead of the correct character
                {
                    DefaultCode = codePoints.FirstOrDefault();
                }
            }
        }
Exemple #4
0
        /**
         * <summary>Loads font information from existing PDF font structure.</summary>
         */
        protected void Load(
            )
        {
            if (BaseDataObject.ContainsKey(PdfName.ToUnicode)) // To-Unicode explicit mapping.
            {
                PdfStream  toUnicodeStream = (PdfStream)BaseDataObject.Resolve(PdfName.ToUnicode);
                CMapParser parser          = new CMapParser(toUnicodeStream.Body);
                codes    = new BiDictionary <ByteArray, int>(parser.Parse());
                symbolic = false;
            }

            OnLoad();

            // Maximum character code length.
            foreach (ByteArray charCode in codes.Keys)
            {
                if (charCode.Data.Length > charCodeMaxLength)
                {
                    charCodeMaxLength = charCode.Data.Length;
                }
            }
            // Missing character substitute.
            if (defaultCode == UndefinedDefaultCode)
            {
                ICollection <int> codePoints = CodePoints;
                if (codePoints.Contains((int)'?'))
                {
                    DefaultCode = '?';
                }
                else if (codePoints.Contains((int)' '))
                {
                    DefaultCode = ' ';
                }
                else
                {
                    DefaultCode = codePoints.First();
                }
            }
        }
Exemple #5
0
        /**
         * <summary>Loads font information from existing PDF font structure.</summary>
         */
        protected void Load(
            )
        {
            if (BaseDataObject.ContainsKey(PdfName.ToUnicode)) // To-Unicode explicit mapping.
            {
                PdfStream  toUnicodeStream = (PdfStream)BaseDataObject.Resolve(PdfName.ToUnicode);
                CMapParser parser          = new CMapParser(toUnicodeStream.Body);
                codes    = new BiDictionary <ByteArray, int>(parser.Parse());
                symbolic = false;
            }

            OnLoad();

            // Maximum character code length.
            foreach (ByteArray charCode in codes.Keys)
            {
                if (charCode.Data.Length > charCodeMaxLength)
                {
                    charCodeMaxLength = charCode.Data.Length;
                }
            }
        }