Package com.itextpdf.text.pdf

Examples of com.itextpdf.text.pdf.PdfArray


      structParents = page.getAsNumber(PdfName.STRUCTPARENTS);
      if (structParents == null)
        throw new DocumentException(MessageLocalization.getComposedMessage("can.t.read.document.structure"));
      annots = page.getAsArray(PdfName.ANNOTS);
      if (annots == null)
        annots = new PdfArray();
      PdfDictionary resources = page.getAsDict(PdfName.RESOURCES);
      xobjects = resources.getAsDict(PdfName.XOBJECT);
      if (xobjects == null) {
        xobjects = new PdfDictionary();
        resources.put(PdfName.XOBJECT, xobjects);
View Full Code Here


      items.removeFromParentTree(structParent);
      // Adding the XObject to the page
      PdfName xobj = new PdfName("XObj" + structParent.intValue());
      LOGGER.info("Creating XObject with name " + xobj);
      xobjects.put(xobj, xobjr);
      PdfArray array = dict.getAsArray(PdfName.RECT);
      // Getting the position of the annotation
      Rectangle rect = new Rectangle(
          array.getAsNumber(0).floatValue(), array.getAsNumber(1).floatValue(),
          array.getAsNumber(2).floatValue(), array.getAsNumber(3).floatValue());
      rect.normalize();
      // A Do operator is forbidden inside a text block
      if (inText && !btWrite) {
        LOGGER.debug("Introducing extra ET");
        baos.write("ET\n".getBytes());
View Full Code Here

   * Constructs a PDF Collection Sort Dictionary.
   * @param keys  the keys of the fields that will be used to sort entries
   */
  public PdfCollectionSort(String[] keys) {
    super(PdfName.COLLECTIONSORT);
    PdfArray array = new PdfArray();
    for (int i = 0; i < keys.length; i++) {
      array.add(new PdfName(keys[i]));
    }
    put(PdfName.S, array);
  }
View Full Code Here

    PdfObject o = get(PdfName.S);
    if (o instanceof PdfArray) {
      if (((PdfArray)o).size() != ascending.length) {
        throw new IllegalArgumentException(MessageLocalization.getComposedMessage("the.number.of.booleans.in.this.array.doesn.t.correspond.with.the.number.of.fields"));
      }
      PdfArray array = new PdfArray();
      for (int i = 0; i < ascending.length; i++) {
        array.add(new PdfBoolean(ascending[i]));
      }
      put(PdfName.A, array);
    }
    else {
      throw new IllegalArgumentException(MessageLocalization.getComposedMessage("you.need.a.single.boolean.for.this.collection.sort.dictionary"));
View Full Code Here

        PdfDictionary v = af.getSignatureDictionary(fieldName);
        if (v == null)
            throw new DocumentException("No field");
        if (!af.signatureCoversWholeDocument(fieldName))
            throw new DocumentException("Not the last signature");
        PdfArray b = v.getAsArray(PdfName.BYTERANGE);
        long[] gaps = b.asLongArray();
        if (b.size() != 4 || gaps[0] != 0)
            throw new DocumentException("Single exclusion space supported");
        RandomAccessSource readerSource = reader.getSafeFile().createSourceView();
        InputStream rg = new RASInputStream(new RandomAccessSourceFactory().createRanged(readerSource, gaps));
        byte[] signedContent = externalSignatureContainer.sign(rg);
        int spaceAvailable = (int)(gaps[2] - gaps[1]) - 2;
View Full Code Here

    /**
     * A content operator implementation (TJ).
     */
    private static class ShowTextArray implements ContentOperator{
        public void invoke(PdfContentStreamProcessor processor, PdfLiteral operator, ArrayList<PdfObject> operands) {
            PdfArray array = (PdfArray)operands.get(0);
            float tj = 0;
            for (Iterator<PdfObject> i = array.listIterator(); i.hasNext(); ) {
                PdfObject entryObj = i.next();
                if (entryObj instanceof PdfString){
                    processor.displayPdfString((PdfString)entryObj);
                    tj = 0;
                } else {
View Full Code Here

            PdfDictionary gsDic = extGState.getAsDict(dictionaryName);
            if (gsDic == null)
                throw new IllegalArgumentException(MessageLocalization.getComposedMessage("1.is.an.unknown.graphics.state.dictionary", dictionaryName));

            // at this point, all we care about is the FONT entry in the GS dictionary
            PdfArray fontParameter = gsDic.getAsArray(PdfName.FONT);
            if (fontParameter != null){
                CMapAwareDocumentFont font = processor.getFont((PRIndirectReference)fontParameter.getPdfObject(0));
                float size = fontParameter.getAsNumber(1).floatValue();

                processor.gs().font = font;
                processor.gs().fontSize = size;
            }
        }
View Full Code Here

            try {
                contentBytes = ContentByteUtils.getContentBytesFromContentObject(stream);
            } catch (IOException e1) {
                throw new ExceptionConverter(e1);
            }
            final PdfArray matrix = stream.getAsArray(PdfName.MATRIX);

            new PushGraphicsState().invoke(processor, null, null);

            if (matrix != null){
                float a = matrix.getAsNumber(0).floatValue();
                float b = matrix.getAsNumber(1).floatValue();
                float c = matrix.getAsNumber(2).floatValue();
                float d = matrix.getAsNumber(3).floatValue();
                float e = matrix.getAsNumber(4).floatValue();
                float f = matrix.getAsNumber(5).floatValue();
                Matrix formMatrix = new Matrix(a, b, c, d, e, f);

                processor.gs().ctm = formMatrix.multiply(processor.gs().ctm);
            }
View Full Code Here

   * @param ocgs  the removal list
   */
  private void removeOCGsFromArray(PdfDictionary dict, PdfName name, Set<String> ocgs) {
    if (dict == null)
      return;
    PdfArray array = dict.getAsArray(name);
    if (array == null)
      return;
    removeOCGsFromArray(array, ocgs);
  }
View Full Code Here

   * Removes annotations from a page dictionary
   * @param page  a page dictionary
   * @param ocgs  a set of names of OCG layers
   */
  private void removeAnnots(PdfDictionary page, Set<String> ocgs) {
    PdfArray annots = page.getAsArray(PdfName.ANNOTS);
    if (annots == null) return;
    PdfDictionary annot;
    List<Integer> remove = new ArrayList<Integer>();
    for (int i = annots.size(); i > 0; ) {
      annot = annots.getAsDict(--i);
      if (isToBeRemoved(annot.getAsDict(PdfName.OC), ocgs)) {
        remove.add(i);
      }
      else {
        removeOCGsFromArray(annot.getAsDict(PdfName.A), PdfName.STATE, ocgs);
      }
    }
    for (Integer i : remove) {
      annots.remove(i);
    }
  }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.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.