Пример #1
0
        public void CanParseCidSystemInfoAndOtherInformation()
        {
            var input = StringBytesTestConverter.Convert(GoogleDocToUnicodeCmap, false);

            var cmap = cMapParser.Parse(input.Bytes, false);

            Assert.Equal("Adobe", cmap.Info.Registry);
            Assert.Equal("UCS", cmap.Info.Ordering);
            Assert.Equal(0, cmap.Info.Supplement);

            Assert.Equal("Adobe-Identity-UCS", cmap.Name);
            Assert.Equal(2, cmap.Type);
        }
Пример #2
0
        public static CMap Parse(IInputBytes bytes, bool isLenientParsing)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }

            var result = CMapParser.Parse(bytes, isLenientParsing);

            return(result);
        }
Пример #3
0
        private CMap ProcessToUnicode()
        {
            CMap      cmapRet = null;
            PdfObject toUni   = PdfReader.GetPdfObjectRelease(this.font.Get(PdfName.TOUNICODE));

            if (toUni is PRStream)
            {
                try {
                    byte[]     touni      = PdfReader.GetStreamBytes((PRStream)toUni);
                    CMapParser cmapParser = new CMapParser();
                    cmapRet = cmapParser.Parse(new MemoryStream(touni));
                } catch {
                }
            }
            return(cmapRet);
        }
        /**
         * Parses the ToUnicode entry, if present, and constructs a CMap for it
         * @since 2.1.7
         */
        private void ProcessToUnicode()
        {
            PdfObject toUni = PdfReader.GetPdfObjectRelease(fontDic.Get(PdfName.TOUNICODE));

            if (toUni is PRStream)
            {
                try {
                    byte[] touni = PdfReader.GetStreamBytes((PRStream)toUni);

                    CMapParser cmapParser = new CMapParser();
                    toUnicodeCmap = cmapParser.Parse(new MemoryStream(touni));
                } catch {
                    // technically, we should log this or provide some sort of feedback... but sometimes the cmap will be junk, but it's still possible to get text, so we don't want to throw an exception
                    //throw new IllegalStateException("Unable to process ToUnicode map - " + e.GetMessage(), e);
                }
            }
        }