Package org.pdfclown.objects

Examples of org.pdfclown.objects.PdfArray


      for(int index = 0, length = operands.size(); index < length; index++)
      {
        PdfDirectObject operand = operands.get(index);
        if(operand instanceof PdfArray)
        {
          PdfArray operandElements = (PdfArray)operand;
          int operandElementIndex = -1;
          for(PdfDirectObject operandElement : operandElements)
          {
            model.addRow(
              new Object[]
View Full Code Here


  */
  public void setObjects(
    Collection<PdfObjectWrapper<?>> value
    )
  {
    PdfArray objectsDataObject = new PdfArray();
    for(PdfObjectWrapper<?> item : value)
    {
      if(item instanceof Annotation)
        objectsDataObject.add(
          item.getBaseObject()
          );
      else if(item instanceof Field)
        objectsDataObject.add(
          new PdfTextString(((Field)item).getFullName())
          );
      else
        throw new IllegalArgumentException(
          "Invalid 'Hide' action target type (" + item.getClass().getName() + ").\n"
View Full Code Here

            stream.seek(oldOffset); // Restores postcondition (last token should be the dictionary end).

            return dictionary;
          }
        case ArrayBegin:
          PdfArray array = new PdfArray();
          while(true)
          {
            // Value.
            moveNext(); if(tokenType == TokenTypeEnum.ArrayEnd) break;
            // Add the current item to the array!
            array.add((PdfDirectObject)parsePdfObject());
          }
          return array;
        case Real:
          return new PdfReal((Float)token);
        case Boolean:
View Full Code Here

  private void flush(
    IOutputStream stream
    )
  {
    // 1. Body.
    final PdfArray indexArray = new PdfArray();
    final int[] entryFieldSizes = new int[]
      {
        EntryField0Size,
        getFieldSize((int)stream.getLength()), // NOTE: We assume this xref stream is the last indirect object.
        EntryField2Size
      };
    {
      // Get the stream buffer!
      final IBuffer body = getBody();

      // Delete the old entries!
      body.setLength(0);

      // Serializing the entries into the stream buffer...
      int prevObjectNumber = -2; // Previous-entry object number.
      for(XRefEntry entry : entries.values())
      {
        int entryNumber = entry.getNumber();
        if(entryNumber - prevObjectNumber != 1) // Current subsection terminated.
        {
          if(!indexArray.isEmpty())
          {indexArray.add(new PdfInteger(prevObjectNumber-((PdfInteger)indexArray.get(indexArray.size()-1)).getValue()+1));} // Number of entries in the previous subsection.
          indexArray.add(new PdfInteger(entryNumber)); // First object number in the next subsection.
        }
        prevObjectNumber = entryNumber;

        switch(entry.getUsage())
        {
          case Free:
            body.append((byte)FreeEntryType);
            body.append(numberToByteArray(entry.getOffset(),entryFieldSizes[1]));
            body.append(numberToByteArray(entry.getGeneration(),entryFieldSizes[2]));
            break;
          case InUse:
            body.append((byte)InUseEntryType);
            body.append(numberToByteArray(entry.getOffset(),entryFieldSizes[1]));
            body.append(numberToByteArray(entry.getGeneration(),entryFieldSizes[2]));
            break;
          case InUseCompressed:
            body.append((byte)InUseCompressedEntryType);
            body.append(numberToByteArray(entry.getStreamNumber(),entryFieldSizes[1]));
            body.append(numberToByteArray(entry.getOffset(),entryFieldSizes[2]));
            break;
          default:
            throw new UnsupportedOperationException();
        }
      }
      indexArray.add(new PdfInteger(prevObjectNumber-((PdfInteger)indexArray.get(indexArray.size()-1)).getValue()+1)); // Number of entries in the previous subsection.
    }

    // 2. Header.
    {
      final PdfDictionary header = getHeader();
      header.put(
        PdfName.Index,
        indexArray
        );
      header.put(
        PdfName.Size,
        new PdfInteger(file.getIndirectObjects().size()+1)
        );
      header.put(
        PdfName.W,
        new PdfArray(
          new PdfInteger(entryFieldSizes[0]),
          new PdfInteger(entryFieldSizes[1]),
          new PdfInteger(entryFieldSizes[2])
          )
        );
View Full Code Here

      {
        final PdfDictionary header = getHeader();
        final int size = ((PdfInteger)header.get(PdfName.Size)).getValue();
        final int[] entryFieldSizes;
        {
          final PdfArray entryFieldSizesObject = (PdfArray)header.get(PdfName.W);
          entryFieldSizes = new int[entryFieldSizesObject.size()];
          for(int index = 0, length = entryFieldSizes.length; index < length; index++)
          {entryFieldSizes[index] = ((PdfInteger)entryFieldSizesObject.get(index)).getValue();}
        }

        final PdfArray subsectionBounds;
        if(header.containsKey(PdfName.Index))
        {subsectionBounds = (PdfArray)header.get(PdfName.Index);}
        else
        {
          subsectionBounds = new PdfArray();
          subsectionBounds.add(new PdfInteger(0));
          subsectionBounds.add(new PdfInteger(size));
        }

        body.setByteOrder(ByteOrder.BIG_ENDIAN);
        body.seek(0);

        final Iterator<PdfDirectObject> subsectionBoundIterator = subsectionBounds.iterator();
        while(subsectionBoundIterator.hasNext())
        {
          try
          {
            final int start = ((PdfInteger)subsectionBoundIterator.next()).getValue();
View Full Code Here

      values[0] = (T)Action.wrap(getBaseObject(),getContainer());
    }
    else // Multiple actions.
    {
      PdfArray actionObjects = (PdfArray)baseDataObject;
      if(values.length < actionObjects.size())
      {values = (T[])new Object[actionObjects.size()];}

      PdfIndirectObject container = getContainer();
      for(
        int index = 0,
          length = actionObjects.size();
        index < length;
        index++
        )
      {values[index] = (T)Action.wrap(actionObjects.get(index),container);}
    }
    return values;
  }
View Full Code Here

    )
  {
    PdfDataObject baseDataObject = getBaseDataObject();
    if(baseDataObject instanceof PdfDictionary) // Single action.
    {
      PdfArray actionsArray = new PdfArray();
      actionsArray.add(getBaseObject());
      setBaseObject(actionsArray);
      parent.getBaseDataObject().put(PdfName.Next,actionsArray);

      baseDataObject = actionsArray;
    }
View Full Code Here

              PdfName.BC,
              PdfName.CA
            },
            new PdfDirectObject[]
            {
              new PdfArray(new PdfDirectObject[]{new PdfReal(0.9412),new PdfReal(0.9412),new PdfReal(0.9412)}),
              new PdfArray(new PdfDirectObject[]{new PdfInteger(0),new PdfInteger(0),new PdfInteger(0)}),
              new PdfString("4")
            }
            )
          );
        widgetDataObject.put(
View Full Code Here

              PdfName.BC,
              PdfName.CA
            },
            new PdfDirectObject[]
            {
              new PdfArray(new PdfDirectObject[]{new PdfReal(0.9412),new PdfReal(0.9412),new PdfReal(0.9412)}),
              new PdfArray(new PdfDirectObject[]{new PdfInteger(0),new PdfInteger(0),new PdfInteger(0)}),
              new PdfString("l")
            }
            )
          );
        widgetDataObject.put(
View Full Code Here

            PdfName.BG,
            PdfName.BC
          },
          new PdfDirectObject[]
          {
            new PdfArray(new PdfDirectObject[]{new PdfReal(.9),new PdfReal(.9),new PdfReal(.9)}),
            new PdfArray(new PdfDirectObject[]{new PdfInteger(0),new PdfInteger(0),new PdfInteger(0)})
          }
          )
        );
    }
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.