All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pdfjet.PDFobj Maven / Gradle / Ivy
/* */ package com.pdfjet;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.Collections;
/* */ import java.util.List;
/* */ import java.util.Map;
/* */
/* */ public class PDFobj
/* */ {
/* */ protected int number;
/* */ protected int offset;
/* */ protected List dict;
/* */ protected int stream_offset;
/* */ protected byte[] stream;
/* */ protected byte[] data;
/* */
/* */ public PDFobj(int paramInt)
/* */ {
/* 59 */ this.offset = paramInt;
/* 60 */ this.dict = new ArrayList();
/* */ }
/* */
/* */ protected PDFobj()
/* */ {
/* 65 */ this.dict = new ArrayList();
/* */ }
/* */
/* */ public int getNumber()
/* */ {
/* 70 */ return this.number;
/* */ }
/* */
/* */ public List getDict()
/* */ {
/* 80 */ return this.dict;
/* */ }
/* */
/* */ public byte[] getData()
/* */ {
/* 90 */ return this.data;
/* */ }
/* */
/* */ protected void setStream(byte[] paramArrayOfByte, int paramInt)
/* */ {
/* 95 */ this.stream = new byte[paramInt];
/* 96 */ System.arraycopy(paramArrayOfByte, this.stream_offset, this.stream, 0, paramInt);
/* */ }
/* */
/* */ protected void setStream(byte[] paramArrayOfByte)
/* */ {
/* 101 */ this.stream = paramArrayOfByte;
/* */ }
/* */
/* */ protected void setNumber(int paramInt)
/* */ {
/* 106 */ this.number = paramInt;
/* */ }
/* */
/* */ public String getValue(String paramString)
/* */ {
/* 118 */ for (int i = 0; i < this.dict.size(); i++) {
/* 119 */ String str = (String)this.dict.get(i);
/* 120 */ if (str.equals(paramString)) {
/* 121 */ return (String)this.dict.get(i + 1);
/* */ }
/* */ }
/* 124 */ return "";
/* */ }
/* */
/* */ protected List getObjectNumbers(String paramString)
/* */ {
/* 129 */ ArrayList localArrayList = new ArrayList();
/* 130 */ for (int i = 0; i < this.dict.size(); i++) {
/* 131 */ String str1 = (String)this.dict.get(i);
/* 132 */ if (str1.equals(paramString)) {
/* 133 */ String str2 = (String)this.dict.get(++i);
/* 134 */ if (str2.equals("[")) {
/* */ while (true) {
/* 136 */ str2 = (String)this.dict.get(++i);
/* 137 */ if (str2.equals("]")) {
/* */ break;
/* */ }
/* 140 */ localArrayList.add(Integer.valueOf(str2));
/* 141 */ i++;
/* 142 */ i++;
/* */ }
/* */ }
/* */
/* 146 */ localArrayList.add(Integer.valueOf(str2));
/* */
/* 148 */ break;
/* */ }
/* */ }
/* 151 */ return localArrayList;
/* */ }
/* */
/* */ public void addContent(byte[] paramArrayOfByte, Map paramMap)
/* */ {
/* 156 */ PDFobj localPDFobj = new PDFobj();
/* 157 */ localPDFobj.setNumber(((Integer)Collections.max(paramMap.keySet())).intValue() + 1);
/* 158 */ localPDFobj.setStream(paramArrayOfByte);
/* 159 */ paramMap.put(Integer.valueOf(localPDFobj.getNumber()), localPDFobj);
/* */
/* 161 */ int i = -1;
/* 162 */ int j = 0;
/* 163 */ for (int k = 0; k < this.dict.size(); k++) {
/* 164 */ if (((String)this.dict.get(k)).equals("/Contents")) {
/* 165 */ String str = (String)this.dict.get(++k);
/* 166 */ if (str.equals("[")) {
/* */ while (true) {
/* 168 */ str = (String)this.dict.get(++k);
/* 169 */ if (str.equals("]")) {
/* 170 */ i = k;
/* 171 */ break;
/* */ }
/* 173 */ k++;
/* 174 */ k++;
/* */ }
/* */
/* */ }
/* */
/* 179 */ i = k;
/* 180 */ j = 1;
/* */
/* 182 */ break;
/* */ }
/* */ }
/* */
/* 186 */ if (j != 0) {
/* 187 */ this.dict.add(i, "[");
/* 188 */ this.dict.add(i + 4, "]");
/* 189 */ this.dict.add(i + 4, "R");
/* 190 */ this.dict.add(i + 4, "0");
/* 191 */ this.dict.add(i + 4, String.valueOf(localPDFobj.number));
/* */ }
/* */ else {
/* 194 */ this.dict.add(i, "R");
/* 195 */ this.dict.add(i, "0");
/* 196 */ this.dict.add(i, String.valueOf(localPDFobj.number));
/* */ }
/* */ }
/* */
/* */ public float[] getPageSize()
/* */ {
/* 202 */ for (int i = 0; i < this.dict.size(); i++) {
/* 203 */ if (((String)this.dict.get(i)).equals("/MediaBox")) {
/* 204 */ return new float[] { Float.valueOf((String)this.dict.get(i + 4)).floatValue(), Float.valueOf((String)this.dict.get(i + 5)).floatValue() };
/* */ }
/* */
/* */ }
/* */
/* 209 */ return Letter.PORTRAIT;
/* */ }
/* */
/* */ protected int getLength(List paramList)
/* */ {
/* 214 */ for (int i = 0; i < this.dict.size(); i++) {
/* 215 */ String str = (String)this.dict.get(i);
/* 216 */ if (str.equals("/Length")) {
/* 217 */ int j = Integer.valueOf((String)this.dict.get(i + 1)).intValue();
/* 218 */ if ((((String)this.dict.get(i + 2)).equals("0")) && (((String)this.dict.get(i + 3)).equals("R")))
/* */ {
/* 220 */ return getLength(paramList, j);
/* */ }
/* */
/* 223 */ return j;
/* */ }
/* */ }
/* */
/* 227 */ return 0;
/* */ }
/* */
/* */ protected int getLength(List paramList, int paramInt)
/* */ {
/* 232 */ for (PDFobj localPDFobj : paramList) {
/* 233 */ if (localPDFobj.number == paramInt) {
/* 234 */ return Integer.valueOf((String)localPDFobj.dict.get(3)).intValue();
/* */ }
/* */ }
/* 237 */ return 0;
/* */ }
/* */
/* */ public PDFobj getContentsObject(Map paramMap)
/* */ {
/* 242 */ for (int i = 0; i < this.dict.size(); i++) {
/* 243 */ if (((String)this.dict.get(i)).equals("/Contents")) {
/* 244 */ if (((String)this.dict.get(i + 1)).equals("[")) {
/* 245 */ return (PDFobj)paramMap.get(Integer.valueOf((String)this.dict.get(i + 2)));
/* */ }
/* 247 */ return (PDFobj)paramMap.get(Integer.valueOf((String)this.dict.get(i + 1)));
/* */ }
/* */ }
/* 250 */ return null;
/* */ }
/* */
/* */ public PDFobj getResourcesObject(Map paramMap)
/* */ {
/* 255 */ for (int i = 0; i < this.dict.size(); i++) {
/* 256 */ if (((String)this.dict.get(i)).equals("/Resources")) {
/* 257 */ return (PDFobj)paramMap.get(Integer.valueOf((String)this.dict.get(i + 1)));
/* */ }
/* */ }
/* 260 */ return null;
/* */ }
/* */
/* */ public Font addFontResource(CoreFont paramCoreFont, Map paramMap)
/* */ {
/* 265 */ Font localFont = new Font(paramCoreFont);
/* 266 */ localFont.fontID = localFont.name.replace('-', '_').toUpperCase();
/* */
/* 268 */ PDFobj localPDFobj = new PDFobj();
/* 269 */ localPDFobj.number = (((Integer)Collections.max(paramMap.keySet())).intValue() + 1);
/* 270 */ localPDFobj.dict.add("<<");
/* 271 */ localPDFobj.dict.add("/Type");
/* 272 */ localPDFobj.dict.add("/Font");
/* 273 */ localPDFobj.dict.add("/Subtype");
/* 274 */ localPDFobj.dict.add("/Type1");
/* 275 */ localPDFobj.dict.add("/BaseFont");
/* 276 */ localPDFobj.dict.add("/" + localFont.name);
/* 277 */ if ((!localFont.name.equals("Symbol")) && (!localFont.name.equals("ZapfDingbats"))) {
/* 278 */ localPDFobj.dict.add("/Encoding");
/* 279 */ localPDFobj.dict.add("/WinAnsiEncoding");
/* */ }
/* 281 */ localPDFobj.dict.add(">>");
/* */
/* 283 */ paramMap.put(Integer.valueOf(localPDFobj.number), localPDFobj);
/* */
/* 285 */ for (int i = 0; i < this.dict.size(); i++) {
/* 286 */ if (((String)this.dict.get(i)).equals("/Resources")) {
/* 287 */ String str = (String)this.dict.get(++i);
/* 288 */ if (str.equals("<<")) {
/* 289 */ addFontResource(this, paramMap, localFont.fontID, localPDFobj.number);
/* */ }
/* 291 */ else if (Character.isDigit(str.charAt(0))) {
/* 292 */ addFontResource((PDFobj)paramMap.get(Integer.valueOf(str)), paramMap, localFont.fontID, localPDFobj.number);
/* */ }
/* */ }
/* */ }
/* */
/* 297 */ return localFont;
/* */ }
/* */
/* */ private void addFontResource(PDFobj paramPDFobj, Map paramMap, String paramString, int paramInt)
/* */ {
/* 303 */ for (int i = 0; i < paramPDFobj.dict.size(); i++) {
/* 304 */ String str = null;
/* 305 */ if (((String)paramPDFobj.dict.get(i)).equals("/Font")) {
/* 306 */ str = (String)paramPDFobj.dict.get(++i);
/* 307 */ if (str.equals("<<")) {
/* 308 */ paramPDFobj.dict.add(++i, "/" + paramString);
/* 309 */ paramPDFobj.dict.add(++i, String.valueOf(paramInt));
/* 310 */ paramPDFobj.dict.add(++i, "0");
/* 311 */ paramPDFobj.dict.add(++i, "R");
/* 312 */ break;
/* */ }
/* 314 */ if (Character.isDigit(str.charAt(0))) {
/* 315 */ PDFobj localPDFobj = (PDFobj)paramMap.get(Integer.valueOf(str));
/* 316 */ for (int j = 0; j < localPDFobj.dict.size(); j++) {
/* 317 */ str = (String)localPDFobj.dict.get(j);
/* 318 */ if (str.equals("<<")) {
/* 319 */ localPDFobj.dict.add(++j, "/" + paramString);
/* 320 */ localPDFobj.dict.add(++j, String.valueOf(paramInt));
/* 321 */ localPDFobj.dict.add(++j, "0");
/* 322 */ localPDFobj.dict.add(++j, "R");
/* 323 */ break;
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* */ }
/* Location: E:\EGGWIFI\Customer\trunk\src\Workspace\Customer\Customer Maven Webapp\src\main\webapp\WEB-INF\lib\PDFjet.jar
* Qualified Name: com.pdfjet.PDFobj
* JD-Core Version: 0.6.2
*/