예제 #1
0
  @SuppressWarnings("unchecked")
  public static void main_3(String[] args) throws IOException {

    PDDocument doc = PDDocument.load(iconFile);

    List<PDPage> pages = doc.getDocumentCatalog().getAllPages();

    List<COSObject> objects = doc.getDocument().getObjects();

    for (COSObject cosObject : objects) {

      COSBase cosbase = cosObject.getObject();

      if (cosObject.getObject() instanceof COSStream) {

        COSStream cosstream = (COSStream) cosbase;

        COSBase filter = cosstream.getDictionaryObject(COSName.FILTER);

        COSBase subtype = cosstream.getDictionaryObject(COSName.SUBTYPE);

        if (subtype != null && subtype.equals(COSName.IMAGE)) {

          System.out.println(filter);

          InputStream filtered = cosstream.getFilteredStream();
          // PDStream stream = new PDStream(costream);

          System.out.println(Hex.encodeHex(IOUtils.toByteArray(filtered)));
        }
      }
    }

    for (PDPage pdPage : pages) {

      PDResources resources = pdPage.getResources();

      Map<String, PDXObject> images = resources.getXObjects();

      Set<String> keys = images.keySet();

      for (String key : keys) {

        PDXObject image = images.get(key);

        byte[] imgData = image.getPDStream().getByteArray();

        System.out.println(Hex.encodeHex(imgData));
      }
    }
  }
예제 #2
0
  protected PDFunction getTintTransformer(COSStream xstream) throws IOException {
    COSBase cs = xstream.getDictionaryObject(COSName.COLORSPACE, COSName.CS);
    if (cs == null) {
      return null;
    }

    COSArray array = getCOSArray(cs);
    if (array == null) {
      return null;
    }
    String name = ((COSName) array.getObject(0)).getName();

    if (name.equals("DeviceN")) {
      PDFunction function = PDFunction.create(array.getObject(3));
      return function;
    }

    return null;
  }
 /**
  * This will get an object from this streams dictionary and dereference it if necessary.
  *
  * @param key The key to the object.
  * @return The dictionary object with the key or null if one does not exist.
  */
 public COSBase getDictionaryObject(COSName key) {
   return firstStream.getDictionaryObject(key);
 }