Examples of PdfDictionary


Examples of com.lowagie.text.pdf.PdfDictionary

        PageRotation[] rotations = inputCommand.getRotations();
        if (rotations != null && rotations.length > 0) {
            if (rotations.length > 1) {
                for (int i = 0; i < rotations.length; i++) {
                    if (pdfNumberOfPages >= rotations[i].getPageNumber() && rotations[i].getPageNumber() > 0) {
                        PdfDictionary dictionary = rotationReader.getPageN(rotations[i].getPageNumber());
                        int rotation = (rotations[i].getDegrees() + rotationReader.getPageRotation(rotations[i]
                                .getPageNumber())) % 360;
                        dictionary.put(PdfName.ROTATE, new PdfNumber(rotation));
                    } else {
                        LOG.warn("Rotation for page " + rotations[i].getPageNumber() + " ignored.");
                    }
                }
            } else {
                // rotate all
                if (rotations[0].getType() == PageRotation.ALL_PAGES) {
                    int pageRotation = rotations[0].getDegrees();
                    for (int i = 1; i <= pdfNumberOfPages; i++) {
                        PdfDictionary dictionary = rotationReader.getPageN(i);
                        int rotation = (pageRotation + rotationReader.getPageRotation(i)) % 360;
                        dictionary.put(PdfName.ROTATE, new PdfNumber(rotation));
                    }
                } else if (rotations[0].getType() == PageRotation.SINGLE_PAGE) {
                    // single page rotation
                    if (pdfNumberOfPages >= rotations[0].getPageNumber() && rotations[0].getPageNumber() > 0) {
                        PdfDictionary dictionary = rotationReader.getPageN(rotations[0].getPageNumber());
                        int rotation = (rotations[0].getDegrees() + rotationReader.getPageRotation(rotations[0]
                                .getPageNumber())) % 360;
                        dictionary.put(PdfName.ROTATE, new PdfNumber(rotation));
                    } else {
                        LOG.warn("Rotation for page " + rotations[0].getPageNumber() + " ignored.");
                    }
                } else if (rotations[0].getType() == PageRotation.ODD_PAGES) {
                    // odd pages rotation
                    int pageRotation = rotations[0].getDegrees();
                    for (int i = 1; i <= pdfNumberOfPages; i = i + 2) {
                        PdfDictionary dictionary = rotationReader.getPageN(i);
                        int rotation = (pageRotation + rotationReader.getPageRotation(i)) % 360;
                        dictionary.put(PdfName.ROTATE, new PdfNumber(rotation));
                    }
                } else if (rotations[0].getType() == PageRotation.EVEN_PAGES) {
                    // even pages rotation
                    int pageRotation = rotations[0].getDegrees();
                    for (int i = 2; i <= pdfNumberOfPages; i = i + 2) {
                        PdfDictionary dictionary = rotationReader.getPageN(i);
                        int rotation = (pageRotation + rotationReader.getPageRotation(i)) % 360;
                        dictionary.put(PdfName.ROTATE, new PdfNumber(rotation));
                    }
                } else {
                    LOG.warn("Unable to find the rotation type. " + rotations[0]);
                }
            }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfDictionary

      } catch (NumberFormatException ex) {}
    }
    if (colSpan > 1 || rowSpan > 1)
    {
      PdfArray a = new PdfArray();
      PdfDictionary dict = new PdfDictionary();
      if (colSpan > 1)
      {
        dict.put(new PdfName("ColSpan"), new PdfNumber(colSpan));
      }
      if (rowSpan > 1)
      {
        dict.put(new PdfName("RowSpan"), new PdfNumber(rowSpan));
      }
      dict.put(PdfName.O, new PdfName("Table"));
      a.add(dict);
      parentTag.put(PdfName.A, a);
    }
  }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfDictionary

      PdfIndirectObject swfRef;
      boolean newContext = !existingContexts.containsKey(exporterContext);
      if (newContext)
      {
        // add the Adobe 1.7 extensions catalog dictionary
        PdfDictionary extensions = new PdfDictionary();
        PdfDictionary adobeExtension = new PdfDictionary();
        adobeExtension.put(new PdfName("BaseVersion"), PdfWriter.PDF_VERSION_1_7);
        adobeExtension.put(new PdfName("ExtensionLevel"), new PdfNumber(3));
        extensions.put(new PdfName("ADBE"), adobeExtension);
        writer.getExtraCatalog().put(new PdfName("Extensions"), extensions);
       
        // add the swf file
        byte[] swfData = readSwf();
        PdfFileSpecification swfFile = PdfFileSpecification.fileEmbedded(writer,
            null, "Open Flash Chart", swfData);
        swfRef = writer.addToBody(swfFile);
        existingContexts.put(exporterContext, swfRef);
      }
      else
      {
        swfRef = (PdfIndirectObject) existingContexts.get(exporterContext);
      }
     
      Rectangle rect = new Rectangle(element.getX() + exporterContext.getOffsetX(),
          exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY(),
          element.getX() + exporterContext.getOffsetX() + element.getWidth(),
          exporterContext.getExportedReport().getPageHeight() - element.getY() - exporterContext.getOffsetY() - element.getHeight());
      PdfAnnotation ann = new PdfAnnotation(writer, rect);
      ann.put(PdfName.SUBTYPE, new PdfName("RichMedia"));
     
      PdfDictionary settings = new PdfDictionary();
      PdfDictionary activation = new PdfDictionary();
      activation.put(new PdfName("Condition"), new PdfName("PV"));
      settings.put(new PdfName("Activation"), activation);
      ann.put(new PdfName("RichMediaSettings"), settings);
     
      PdfDictionary content = new PdfDictionary();
     
      HashMap assets = new HashMap();
      assets.put("map.swf", swfRef.getIndirectReference());
      PdfDictionary assetsDictionary = PdfNameTree.writeTree(assets, writer);
      content.put(new PdfName("Assets"), assetsDictionary);
     
      PdfArray configurations = new PdfArray();
      PdfDictionary configuration = new PdfDictionary();
     
      PdfArray instances = new PdfArray();
      PdfDictionary instance = new PdfDictionary();
      instance.put(new PdfName("Subtype"), new PdfName("Flash"));
      PdfDictionary params = new PdfDictionary();
     
      String chartData = (String) element.getParameterValue(PARAMETER_CHART_DATA);
      String vars = "inline_data=" + chartData;
      params.put(new PdfName("FlashVars"), new PdfString(vars));
      instance.put(new PdfName("Params"), params);
      instance.put(new PdfName("Asset"), swfRef.getIndirectReference());
      PdfIndirectObject instanceRef = writer.addToBody(instance);
      instances.add(instanceRef.getIndirectReference());
      configuration.put(new PdfName("Instances"), instances);
View Full Code Here

Examples of org.apache.fop.pdf.PDFDictionary

   
    /** {@inheritDoc} */
    public void setup(PDFDocument doc) {
        pdfFilter = new CCFFilter();
        pdfFilter.setApplied(true);
        PDFDictionary dict = new PDFDictionary();
        dict.put("Columns", this.image.getSize().getWidthPx());
        int compression = getImage().getCompression();
        switch (compression) {
        case TIFFImage.COMP_FAX_G3_1D :
            dict.put("K", 0);
            break;
        case TIFFImage.COMP_FAX_G3_2D :
            dict.put("K", 1);
            break;
        case TIFFImage.COMP_FAX_G4_2D :
            dict.put("K", -1);
            break;
        default:
            throw new IllegalStateException("Invalid compression scheme: " + compression);
        }
        ((CCFFilter)pdfFilter).setDecodeParms(dict);
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

              );
          }
        }
        else if(operand instanceof PdfDictionary)
        {
          PdfDictionary operandEntries = (PdfDictionary)operand;
          int operandEntryIndex = -1;
          for(Map.Entry<PdfName,PdfDirectObject> operandEntry : operandEntries.entrySet())
          {
            model.addRow(
              new Object[]
              {
                "(operand " + index + "." + (++operandEntryIndex) + ") " + operandEntry.getKey().toString(),
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

    )
  {
    if(baseObject == null)
      return null;

    PdfDictionary dataObject = (PdfDictionary)File.resolve(baseObject);
    PdfName actionType = (PdfName)dataObject.get(PdfName.S);
    if(actionType == null
      || (dataObject.containsKey(PdfName.Type)
          && !dataObject.get(PdfName.Type).equals(PdfName.Action)))
      return null;

    if(actionType.equals(PdfName.GoTo))
      return new GoToLocal(baseObject,container);
    else if(actionType.equals(PdfName.GoToR))
      return new GoToRemote(baseObject,container);
    else if(actionType.equals(PdfName.GoToE))
      return new GoToEmbedded(baseObject,container);
    else if(actionType.equals(PdfName.Launch))
      return new Launch(baseObject,container);
    else if(actionType.equals(PdfName.Thread))
      return new GoToThread(baseObject,container);
    else if(actionType.equals(PdfName.URI))
      return new GoToURI(baseObject,container);
    else if(actionType.equals(PdfName.Sound))
      return new PlaySound(baseObject,container);
    else if(actionType.equals(PdfName.Movie))
      return new PlayMovie(baseObject,container);
    else if(actionType.equals(PdfName.Hide))
      return new ToggleVisibility(baseObject,container);
    else if(actionType.equals(PdfName.Named))
    {
      PdfName actionName = (PdfName)dataObject.get(PdfName.N);
      if(actionName.equals(PdfName.NextPage))
        return new GoToNextPage(baseObject,container);
      else if(actionName.equals(PdfName.PrevPage))
        return new GoToPreviousPage(baseObject,container);
      else if(actionName.equals(PdfName.FirstPage))
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

    PdfName actionType
    )
  {
    super(
      context.getFile(),
      new PdfDictionary(
        new PdfName[]
        {
          PdfName.Type,
          PdfName.S
        },
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

      body.append(dataBuffer);
    }

    // 2. Header.
    {
      final PdfDictionary header = getHeader();
      header.put(
        PdfName.N,
        new PdfInteger(getEntries().size())
        );
      header.put(
        PdfName.First,
        new PdfInteger(dataByteOffset)
        );
    }
  }
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

      TargetObject target
      )
    {
      super(
        context.getFile(),
        new PdfDictionary()
        );

      setRelation(relation);
      setEmbeddedFileName(embeddedFileName);
      setAnnotationPageRef(annotationPageRef);
View Full Code Here

Examples of org.pdfclown.objects.PdfDictionary

        case Literal:
          return new PdfTextString(
            Encoding.encode((String)token)
            );
        case DictionaryBegin:
          PdfDictionary dictionary = new PdfDictionary();
          while(true)
          {
            // Key.
            moveNext(); if(tokenType == TokenTypeEnum.DictionaryEnd) break;
            PdfName key = (PdfName)parsePdfObject();
            // Value.
            moveNext();
            PdfDirectObject value = (PdfDirectObject)parsePdfObject();
            // Add the current entry to the dictionary!
            dictionary.put(key,value);
          }

          int oldOffset = (int)stream.getPosition();
          moveNext();
          // Is this dictionary the header of a stream object [PDF:1.6:3.2.7]?
          if((tokenType == TokenTypeEnum.Keyword)
            && token.equals(Keyword.BeginStream)) // Stream.
          {
            // Keep track of current position!
            long position = stream.getPosition();

            // Get the stream length!
            /*
              NOTE: Indirect reference resolution is an outbound call (stream pointer hazard!),
              so we need to recover our current position after it returns.
            */
            int length = ((PdfInteger)File.resolve(dictionary.get(PdfName.Length))).getRawValue();

            // Move to the stream data beginning!
            stream.seek(position); skipEOL();

            // Copy the stream data to the instance!
            byte[] data = new byte[length];
            try
            {stream.read(data);}
            catch(EOFException e)
            {throw new FileFormatException("Unexpected EOF (malformed stream object).",e,stream.getPosition());}

            moveNext(); // Postcondition (last token should be 'endstream' keyword).

            Object streamType = dictionary.get(PdfName.Type);
            if(PdfName.ObjStm.equals(streamType)) // Object stream [PDF:1.6:3.4.6].
              return new ObjectStream(
                dictionary,
                new Buffer(data),
                file
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.