Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
iText io.jar Source Code
io.jar is a component in iText Java library to provide input/output functionalities. iText Java library allows you to generate and manage PDF documents.
The Source Code files are provided together with the JAR file in the binary packge like iText7-Core-7.1.4.zip. You can download it at iText 7 Core Download site.
You can compile it to generate your JAR file, using io.pom as the build configuration file.
The source code of io-7.1.4.jar is provided below:
✍: FYIcenter.com
⏎ com/itextpdf/io/font/FontEncoding.java
/* This file is part of the iText (R) project. Copyright (c) 1998-2018 iText Group NV Authors: Bruno Lowagie, Paulo Soares, et al. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation with the addition of the following permission added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program; if not, see http://www.gnu.org/licenses or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, 02110-1301 USA, or download the license from the following URL: http://itextpdf.com/terms-of-use/ The interactive user interfaces in modified source and object code versions of this program must display Appropriate Legal Notices, as required under Section 5 of the GNU Affero General Public License. In accordance with Section 7(b) of the GNU Affero General Public License, a covered work must retain the producer line in every PDF that is created or manipulated using iText. You can be released from the requirements of the license by purchasing a commercial license. Buying such a license is mandatory as soon as you develop commercial activities involving the iText software without disclosing the source code of your own applications. These activities include: offering paid services to customers as an ASP, serving PDFs on the fly in a web application, shipping iText with a closed source product. For more information, please contact iText Software Corp. at this address: sales@itextpdf.com */ package com.itextpdf.io.font; import com.itextpdf.io.util.ArrayUtil; import com.itextpdf.io.util.IntHashtable; import com.itextpdf.io.util.TextUtil; import java.io.Serializable; import java.util.Objects; import java.util.StringTokenizer; public class FontEncoding implements Serializable { private static final long serialVersionUID = -684967385759439083L; private static final byte[] emptyBytes = new byte[0]; public static final String FONT_SPECIFIC = "FontSpecific"; /** * A not defined character in a custom PDF encoding. */ public static final String NOTDEF = ".notdef"; /** * Base font encoding. */ protected String baseEncoding; /** * {@code true} if the font must use its built in encoding. In that case * the {@code encoding} is only used to map a char to the position inside the font, not to the expected char name. */ protected boolean fontSpecific; /** * Mapping map from unicode to simple code according to the encoding. */ protected IntHashtable unicodeToCode; protected int[] codeToUnicode; /** * Encoding names. */ protected String[] differences; /** * Encodings unicode differences */ protected IntHashtable unicodeDifferences; protected FontEncoding() { unicodeToCode = new IntHashtable(256); codeToUnicode = ArrayUtil.fillWithValue(new int[256], -1); unicodeDifferences = new IntHashtable(256); fontSpecific = false; } public static FontEncoding createFontEncoding(String baseEncoding) { FontEncoding encoding = new FontEncoding(); encoding.baseEncoding = normalizeEncoding(baseEncoding); if (encoding.baseEncoding.startsWith("#")) { encoding.fillCustomEncoding(); } else { encoding.fillNamedEncoding(); } return encoding; } public static FontEncoding createEmptyFontEncoding() { FontEncoding encoding = new FontEncoding(); encoding.baseEncoding = null; encoding.fontSpecific = false; encoding.differences = new String[256]; for (int ch = 0; ch < 256; ch++) { encoding.unicodeDifferences.put(ch, ch); } return encoding; } /** * This encoding will base on font encoding (FontSpecific encoding in Type 1 terminology) */ public static FontEncoding createFontSpecificEncoding() { FontEncoding encoding = new FontEncoding(); encoding.fontSpecific = true; for (int ch = 0; ch < 256; ch++) { encoding.unicodeToCode.put(ch, ch); encoding.codeToUnicode[ch] = ch; encoding.unicodeDifferences.put(ch, ch); } return encoding; } public String getBaseEncoding() { return baseEncoding; } public boolean isFontSpecific() { return fontSpecific; } public boolean addSymbol(int code, int unicode) { if (code < 0 || code > 255) { return false; } String glyphName = AdobeGlyphList.unicodeToName(unicode); if (glyphName != null) { unicodeToCode.put(unicode, code); codeToUnicode[code] = unicode; differences[code] = glyphName; unicodeDifferences.put(unicode, unicode); return true; } else { return false; } } /** * Gets unicode value for corresponding font's char code. * * @param index font's char code * @return -1, if the char code unsupported or valid unicode. */ public int getUnicode(int index) { return codeToUnicode[index]; } public int getUnicodeDifference(int index) { return unicodeDifferences.get(index); } public boolean hasDifferences() { return differences != null; } public String getDifference(int index) { return differences != null ? differences[index] : null; } /** * Converts a {@code String} to a {@code byte} array according to the encoding. * String could contain a unicode symbols or font specific codes. * * @param text the {@code String} to be converted. * @return an array of {@code byte} representing the conversion according to the encoding */ public byte[] convertToBytes(String text) { if (text == null || text.length() == 0) { return emptyBytes; } int ptr = 0; byte[] bytes = new byte[text.length()]; for (int i = 0; i < text.length(); i++) { if (unicodeToCode.containsKey(text.charAt(i))) { bytes[ptr++] = (byte) convertToByte(text.charAt(i)); } } return ArrayUtil.shortenArray(bytes, ptr); } /** * Converts a unicode symbol or font specific code * to {@code byte} according to the encoding. * * @param unicode a unicode symbol or FontSpecif code to be converted. * @return a {@code byte} representing the conversion according to the encoding */ public int convertToByte(int unicode) { return unicodeToCode.get(unicode); } /** * Check whether a unicode symbol or font specific code can be converted * to {@code byte} according to the encoding. * * @param unicode a unicode symbol or font specific code to be checked. * @return {@code true} if {@code ch} could be encoded. */ public boolean canEncode(int unicode) { return unicodeToCode.containsKey(unicode) || TextUtil.isNonPrintable(unicode); } /** * Check whether a {@code byte} code can be converted * to unicode symbol according to the encoding. * * @param code a byte code to be checked. * @return {@code true} if {@code code} could be decoded. */ public boolean canDecode(int code) { return codeToUnicode[code] > -1; } /** * Checks whether the {@link FontEncoding} was built with corresponding encoding. * * @param encoding an encoding * @return true, if the FontEncoding was built with the encoding. Otherwise false. */ public boolean isBuiltWith(String encoding) { return Objects.equals(normalizeEncoding(encoding), baseEncoding); } protected void fillCustomEncoding() { differences = new String[256]; StringTokenizer tok = new StringTokenizer(baseEncoding.substring(1), " ,\t\n\r\f"); if (tok.nextToken().equals("full")) { while (tok.hasMoreTokens()) { String order = tok.nextToken(); String name = tok.nextToken(); char uni = (char) Integer.parseInt(tok.nextToken(), 16); int uniName = AdobeGlyphList.nameToUnicode(name); int orderK; if (order.startsWith("'")) { orderK = order.charAt(1); } else { orderK = Integer.parseInt(order); } orderK %= 256; unicodeToCode.put(uni, orderK); codeToUnicode[orderK] = (int) uni; differences[orderK] = name; unicodeDifferences.put(uni, uniName); } } else { int k = 0; if (tok.hasMoreTokens()) { k = Integer.parseInt(tok.nextToken()); } while (tok.hasMoreTokens() && k < 256) { String hex = tok.nextToken(); int uni = Integer.parseInt(hex, 16) % 0x10000; String name = AdobeGlyphList.unicodeToName(uni); if (name == null) { name = "uni" + hex; } unicodeToCode.put(uni, k); codeToUnicode[k] = uni; differences[k] = name; unicodeDifferences.put(uni, uni); k++; } } for (int k = 0; k < 256; k++) { if (differences[k] == null) { differences[k] = NOTDEF; } } } protected void fillNamedEncoding() { PdfEncodings.convertToBytes(" ", baseEncoding); // check if the encoding exists boolean stdEncoding = PdfEncodings.WINANSI.equals(baseEncoding) || PdfEncodings.MACROMAN.equals(baseEncoding); if (!stdEncoding && differences == null) { differences = new String[256]; } byte[] b = new byte[256]; for (int k = 0; k < 256; ++k) { b[k] = (byte) k; } String str = PdfEncodings.convertToString(b, baseEncoding); char[] encoded = str.toCharArray(); for (int ch = 0; ch < 256; ++ch) { char uni = encoded[ch]; String name = AdobeGlyphList.unicodeToName(uni); if (name == null) { name = NOTDEF; } else { unicodeToCode.put(uni, ch); codeToUnicode[ch] = (int) uni; unicodeDifferences.put(uni, uni); } if (differences != null) { differences[ch] = name; } } } protected void fillStandardEncoding() { int[] encoded = PdfEncodings.standardEncoding; for (int ch = 0; ch < 256; ++ch) { int uni = encoded[ch]; String name = AdobeGlyphList.unicodeToName(uni); if (name == null) { name = NOTDEF; } else { unicodeToCode.put(uni, ch); codeToUnicode[ch] = uni; unicodeDifferences.put(uni, uni); } if (differences != null) { differences[ch] = name; } } } /** * Normalize the encoding names. "winansi" is changed to "Cp1252" and * "macroman" is changed to "MacRoman". * * @param enc the encoding to be normalized * @return the normalized encoding */ protected static String normalizeEncoding(String enc) { String tmp = enc == null ? "" : enc.toLowerCase(); switch (tmp) { case "": case "winansi": case "winansiencoding": return PdfEncodings.WINANSI; case "macroman": case "macromanencoding": return PdfEncodings.MACROMAN; case "zapfdingbatsencoding": return PdfEncodings.ZAPFDINGBATS; default: return enc; } } }
⏎ com/itextpdf/io/font/FontEncoding.java
Or download all of them as a single archive file:
File name: io-7.1.4-sources.jar File size: 608762 bytes Release date: 2018-10-09 Download
⇒ iText layout.jar Source Code
⇐ iText kernel.jar Source Code
2018-04-09, 91438👍, 5💬
Popular Posts:
JasperReports, the world's most popular open source business intelligence and reporting engine and J...
JDK 11 jdk.xml.dom.jmod is the JMOD file for JDK 11 XML DOM module. JDK 11 XML DOM module compiled c...
How to download and install mysql-connector-j-8.0.31 .zip?Connector/J Java library is a JDBC Driver ...
Swingx is the SwingLabs Swing Component Extensions. JAR File Size and Download Location: File name: ...
What is the dom\GetElementsByTagName .javaprovided in the Apache Xerces package? I have Apache Xerce...