Package org.pdfclown.documents.contents

Examples of org.pdfclown.documents.contents.XObjectResources


    XObject value
    )
  {
    // Ensuring that the external object exists within the context resources...
    Resources resources = scanner.getContentContext().getResources();
    XObjectResources xObjects = resources.getXObjects();
    // No external object resources collection?
    if(xObjects == null)
    {
      // Create the external object resources collection!
      xObjects = new XObjectResources(scanner.getContents().getDocument());
      resources.setXObjects(xObjects); resources.update();
    }
    // Get the key associated to the external object!
    PdfName name = xObjects.getBaseDataObject().getKey(value.getBaseObject());
    // No key found?
    if(name == null)
    {
      // Insert the external object within the resources!
      int xObjectIndex = xObjects.size();
      do
      {name = new PdfName(String.valueOf(++xObjectIndex));}
      while(xObjects.containsKey(name));
      xObjects.put(name,value); xObjects.update();
    }

    return name;
  }
View Full Code Here


    XObject imageXObject = image.toXObject(document); // XObject (i.e. external object) is, in PDF spec jargon, a reusable object.
    // Looking for images to replace...
    for(Page page : document.getPages())
    {
      Resources resources = page.getResources();
      XObjectResources xObjects = resources.getXObjects();
      if(xObjects == null)
        continue;

      for(PdfName xObjectKey : xObjects.keySet())
      {
        XObject xObject = xObjects.get(xObjectKey);
        // Is the page's resource an image?
        if(xObject instanceof ImageXObject)
        {
          System.out.println("Substituting " + xObjectKey + " image xobject.");
          xObjects.put(xObjectKey,imageXObject);
          xObjects.update();
        }
      }
/*      for(Map.Entry<PdfName,XObject> xObjectEntry : xObjects.entrySet())
      {
        if(xObjectEntry.getValue() instanceof ImageXObject)
View Full Code Here

TOP

Related Classes of org.pdfclown.documents.contents.XObjectResources

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.