|
82 | 82 | import java.util.Iterator;
|
83 | 83 | import java.util.List;
|
84 | 84 | import java.util.Map;
|
85 |
| -import java.util.RandomAccess; |
86 | 85 |
|
87 | 86 | class PdfStamperImp extends PdfWriter {
|
88 | 87 | HashMap<PdfReader, IntHashtable> readers2intrefs = new HashMap<PdfReader, IntHashtable>();
|
@@ -130,6 +129,24 @@ protected Counter getCounter() {
|
130 | 129 |
|
131 | 130 | //Hash map of standard fonts used in flattening of annotations to prevent fonts duplication
|
132 | 131 | private HashMap<String, PdfIndirectReference> builtInAnnotationFonts = new HashMap<String, PdfIndirectReference>();
|
| 132 | + private static HashMap<String, String> fromShortToFullAnnotationFontNames = new HashMap<String, String>(); |
| 133 | + |
| 134 | + static { |
| 135 | + fromShortToFullAnnotationFontNames.put("CoBO", BaseFont.COURIER_BOLDOBLIQUE); |
| 136 | + fromShortToFullAnnotationFontNames.put("CoBo", BaseFont.COURIER_BOLD); |
| 137 | + fromShortToFullAnnotationFontNames.put("CoOb", BaseFont.COURIER_OBLIQUE); |
| 138 | + fromShortToFullAnnotationFontNames.put("Cour", BaseFont.COURIER); |
| 139 | + fromShortToFullAnnotationFontNames.put("HeBO", BaseFont.HELVETICA_BOLDOBLIQUE); |
| 140 | + fromShortToFullAnnotationFontNames.put("HeBo", BaseFont.HELVETICA_BOLD); |
| 141 | + fromShortToFullAnnotationFontNames.put("HeOb", BaseFont.HELVETICA_OBLIQUE); |
| 142 | + fromShortToFullAnnotationFontNames.put("Helv", BaseFont.HELVETICA); |
| 143 | + fromShortToFullAnnotationFontNames.put("Symb", BaseFont.SYMBOL); |
| 144 | + fromShortToFullAnnotationFontNames.put("TiBI", BaseFont.TIMES_BOLDITALIC); |
| 145 | + fromShortToFullAnnotationFontNames.put("TiBo", BaseFont.TIMES_BOLD); |
| 146 | + fromShortToFullAnnotationFontNames.put("TiIt", BaseFont.TIMES_ITALIC); |
| 147 | + fromShortToFullAnnotationFontNames.put("TiRo", BaseFont.TIMES_ROMAN); |
| 148 | + fromShortToFullAnnotationFontNames.put("ZaDb", BaseFont.ZAPFDINGBATS); |
| 149 | + } |
133 | 150 |
|
134 | 151 | private double[] DEFAULT_MATRIX = {1, 0, 0, 1, 0, 0};
|
135 | 152 |
|
@@ -1309,12 +1326,16 @@ private void flattenAnnotations(boolean flattenFreeTextAnnotations) {
|
1309 | 1326 | if (operator.toString().equals("Tf")) {
|
1310 | 1327 | pdfFontName = (PdfName) operands.get(0);
|
1311 | 1328 | String fontName = pdfFontName.toString().substring(1);
|
1312 |
| - fontReference = builtInAnnotationFonts.get(fontName); |
| 1329 | + String fullName = fromShortToFullAnnotationFontNames.get(fontName); |
| 1330 | + if (fullName == null) { |
| 1331 | + fullName = fontName; |
| 1332 | + } |
| 1333 | + fontReference = builtInAnnotationFonts.get(fullName); |
1313 | 1334 | if (fontReference == null) {
|
1314 |
| - PdfDictionary dic = BaseFont.createBuiltInFontDictionary(fontName); |
| 1335 | + PdfDictionary dic = BaseFont.createBuiltInFontDictionary(fullName); |
1315 | 1336 | if (dic != null) {
|
1316 | 1337 | fontReference = addToBody(dic).getIndirectReference();
|
1317 |
| - builtInAnnotationFonts.put(fontName, fontReference); |
| 1338 | + builtInAnnotationFonts.put(fullName, fontReference); |
1318 | 1339 | }
|
1319 | 1340 | }
|
1320 | 1341 | }
|
|
0 commit comments