internal override void AddChar(PdfString mark, PdfObject code) { byte[] src = mark.GetBytes(); String dest = CreateStringFromBytes(code.GetBytes()); if (src.Length == 1) { singleByteMappings[src[0] & 0xff] = dest; } else if (src.Length == 2) { int intSrc = src[0] & 0xFF; intSrc <<= 8; intSrc |= src[1] & 0xFF; doubleByteMappings[intSrc] = dest; } else { throw new IOException(MessageLocalization.GetComposedMessage("mapping.code.should.be.1.or.two.bytes.and.not.1", src.Length)); } }
private void CreateRawContent(List <byte> rawContent, PdfObject pdfObject) { Type pdfObjectType = pdfObject.GetType(); if (pdfObjectType == typeof(PdfName)) { rawContent.AddRange(pdfObject.GetBytes()); } else if (pdfObjectType == typeof(PdfLiteral)) { string t = pdfObject.ToString(); if (t == "EMC" || t == "BMC" || t == "BDC") { rawContent.Add(BYTE_SPACE); } rawContent.AddRange(pdfObject.GetBytes()); if (t == "BT") { rawContent.AddRange(BYTES_LINE_BREAK_WINDOWS); } if (t == "EMC" || t == "BMC" || t == "BDC") { rawContent.Add(BYTE_SPACE); } } else if (pdfObjectType == typeof(PdfNumber)) { rawContent.AddRange(pdfObject.GetBytes()); } else if (pdfObjectType == typeof(PdfString)) { rawContent.Add(BYTE_ROUND_OPENING_BRACKET); byte[] objectBuffer = pdfObject.GetBytes(); foreach (byte objectByte in objectBuffer) { switch (objectByte) { case BYTE_CARRIAGE_RETURN: { rawContent.AddRange(BYTES_REVERSE_SOLIDUS_AND_CHAR_r); break; } case BYTE_LINE_FEED: { rawContent.AddRange(BYTES_REVERSE_SOLIDUS_AND_CHAR_n); break; } case BYTE_HORIZONTAL_TAB: { rawContent.AddRange(BYTES_REVERSE_SOLIDUS_AND_CHAR_t); break; } case BYTE_BACKSPACE: { rawContent.AddRange(BYTES_REVERSE_SOLIDUS_AND_CHAR_b); break; } case BYTE_FORM_FEED: { rawContent.AddRange(BYTES_REVERSE_SOLIDUS_AND_CHAR_f); break; } case BYTE_ROUND_OPENING_BRACKET: case BYTE_ROUND_CLOSING_BRACKET: case BYTE_REVERSE_SOLIDUS: { rawContent.Add(BYTE_ESCAPE_CHAR); rawContent.Add(objectByte); break; } default: { rawContent.Add(objectByte); break; } } } rawContent.Add(BYTE_ROUND_CLOSING_BRACKET); } else if (pdfObjectType == typeof(PdfDictionary)) { rawContent.AddRange(BYTES_DOUBLE_ANGLE_OPENING_BRACKETS); PdfDictionary dict = pdfObject as PdfDictionary; foreach (PdfObject key in dict.Keys) { CreateRawContent(rawContent, key); PdfName keyName = key as PdfName; this.CreateRawContent(rawContent, dict.Get(keyName)); } rawContent.AddRange(BYTES_DOUBLE_ANGLE_CLOSING_BRACKETS); } else if (pdfObjectType == typeof(PdfArray)) { rawContent.Add(BYTE_SQUARE_OPENING_BRACKET); PdfArray pa = pdfObject as PdfArray; foreach (PdfObject obj in pa.ArrayList) { this.CreateRawContent(rawContent, obj); } rawContent.Add(BYTE_SQUARE_CLOSING_BRACKET); } else { rawContent.AddRange(pdfObject.GetBytes()); } rawContent.Add(BYTE_SPACE); }