Package org.pdfclown.objects

Examples of org.pdfclown.objects.PdfArray


  public boolean addAll(
    int index,
    Collection<? extends Widget> values
    )
  {
    PdfArray items = ensureArray();
    for(Widget value : values)
    {items.add(index++,value.getBaseObject());}

    return true;
  }
View Full Code Here


      values[0] = (T)newWidget(getBaseObject());
    }
    else // Array.
    {
      PdfArray widgetObjects = (PdfArray)baseDataObject;
      if(values.length < widgetObjects.size())
      {values = (T[])new Object[widgetObjects.size()];}

      for(
        int index = 0,
          length = widgetObjects.size();
        index < length;
        index++
        )
      {values[index] = (T)newWidget(widgetObjects.get(index));}
    }
    return values;
  }
View Full Code Here

    )
  {
    PdfDataObject baseDataObject = getBaseDataObject();
    if(baseDataObject instanceof PdfDictionary) // Merged annotation.
    {
      PdfArray widgetsArray = new PdfArray();
      {
        PdfDictionary fieldDictionary = (PdfDictionary)baseDataObject;
        PdfDictionary widgetDictionary = null;
        // Extracting widget entries from the field...
        for(PdfName key : new HashMap<PdfName,PdfDirectObject>(fieldDictionary).keySet())
        {
          // Is it a widget entry?
          if(key.equals(PdfName.Type)
            || key.equals(PdfName.Subtype)
            || key.equals(PdfName.Rect)
            || key.equals(PdfName.Contents)
            || key.equals(PdfName.P)
            || key.equals(PdfName.NM)
            || key.equals(PdfName.M)
            || key.equals(PdfName.F)
            || key.equals(PdfName.BS)
            || key.equals(PdfName.AP)
            || key.equals(PdfName.AS)
            || key.equals(PdfName.Border)
            || key.equals(PdfName.C)
            || key.equals(PdfName.A)
            || key.equals(PdfName.AA)
            || key.equals(PdfName.StructParent)
            || key.equals(PdfName.OC)
            || key.equals(PdfName.H)
            || key.equals(PdfName.MK))
          {
            if(widgetDictionary == null)
            {
              widgetDictionary = new PdfDictionary();
              PdfReference widgetReference = getFile().register(widgetDictionary);

              // Remove the field from the page annotations (as the widget annotation is decoupled from it)!
              PdfArray pageAnnotationsArray = (PdfArray)File.resolve(((PdfDictionary)File.resolve(fieldDictionary.get(PdfName.P))).get(PdfName.Annots));
              pageAnnotationsArray.remove(field.getBaseObject());

              // Add the widget to the page annotations!
              pageAnnotationsArray.add(widgetReference);
              // Add the widget to the field widgets!
              widgetsArray.add(widgetReference);
              // Associate the field to the widget!
              widgetDictionary.put(PdfName.Parent,field.getBaseObject());
            }
View Full Code Here

      // Define the action type (in this case: go-to)!
      action.put(new PdfName("S"),new PdfName("GoTo"));
      // Defining the action destination...
      {
        // Create the destination array!
        PdfArray destination = new PdfArray();
        // Define the 2nd page as the destination target!
        destination.add(document.getPages().get(1).getBaseObject());
        // Define the location of the document window on the page (fit vertically)!
        destination.add(new PdfName("FitV"));
        // Define the window's left-edge horizontal coordinate!
        destination.add(new PdfInteger(-32768));
        // Associate the destination to the action!
        action.put(new PdfName("D"),destination);
      }
      // Associate the action to the document!
      document.getBaseDataObject().put(
View Full Code Here

  @Override
  public void setValue(
    List<Object> value
    )
  {
    PdfArray elements = new PdfArray();
    operands.set(0,elements);
    boolean textItemExpected = true;
    for(Object valueItem : value)
    {
      PdfDirectObject element;
      if(textItemExpected)
      {element = new PdfString((byte[])valueItem);}
      else
      {element = new PdfReal((Double)valueItem);}
      elements.add(element);

      textItemExpected = !textItemExpected;
    }
  }
View Full Code Here

        new PdfDirectObject[]
        {
          PdfName.Annot,
          subtype,
          page.getBaseObject(),
          new PdfArray(new PdfDirectObject[]{new PdfInteger(0),new PdfInteger(0),new PdfInteger(0)}) // NOTE: Hide border by default.
        }
        )
      );

    {
      setBox(box);

      PdfArray pageAnnotsObject = (PdfArray)File.resolve(page.getBaseDataObject().get(PdfName.Annots));
      if(pageAnnotsObject == null)
      {page.getBaseDataObject().put(PdfName.Annots,pageAnnotsObject = new PdfArray());}
      pageAnnotsObject.add(getBaseObject());
    }
  }
View Full Code Here

    Document context
    )
  {
    super(
      context.getFile(),
      new PdfArray()
      );
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public <T> T[] toArray(
    T[] values
    )
  {
    PdfArray itemObjects = (PdfArray)getBaseDataObject();
    if(values.length < itemObjects.size())
    {values = (T[])new Object[itemObjects.size()];}

    PdfIndirectObject container = getContainer();
    for(
      int index = 0,
        length = itemObjects.size();
      index < length;
      index++
      )
    {values[index] = (T)new ChoiceItem(itemObjects.get(index),container,this);}

    return values;
  }
View Full Code Here

            }
            return dictionary;
          }
        case ArrayBegin:
          {
            PdfArray array = new PdfArray();
            // Populate the array.
            while(true)
            {
              // Value.
              moveNext();
              if(tokenType == TokenTypeEnum.ArrayEnd)
                break;

              // Add the current item to the array!
              array.add(parsePdfObject());
            }
            return array;
          }
        case Real:
          return new PdfReal((Float)token);
View Full Code Here

          : null);
      }
    }
    else // Multiple streams.
    {
      PdfArray streams = (PdfArray)contentStream;
      if(streamIndex < streams.size())
      {
        streamIndex++;

        basePosition = (streamIndex == 0
          ? 0
          : basePosition + stream.getLength());

        stream = (streamIndex < streams.size()
          ? ((PdfStream)streams.resolve(streamIndex)).getBody()
          : null);
      }
    }
    if(stream == null)
      return false;
View Full Code Here

TOP

Related Classes of org.pdfclown.objects.PdfArray

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.