Package org.pdfclown.objects

Examples of org.pdfclown.objects.PdfName


  {
    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))
        return new GoToFirstPage(baseObject,container);
      else if(actionName.equals(PdfName.LastPage))
        return new GoToLastPage(baseObject,container);
      else // Custom named action.
        return new NamedAction(baseObject,container);
    }
    else if(actionType.equals(PdfName.SubmitForm))
View Full Code Here


      switch(tokenType)
      {
        case Integer:
          return new PdfInteger((Integer)token);
        case Name:
          return new PdfName((String)token,true);
        case Reference:
          /*
            NOTE: Curiously, PDF references are the only primitive objects that require
            a file reference. That's because they deal with indirect objects, which are strongly
            coupled with the current state of the file: so, PDF references are the fundamental
            bridge between the token layer and the file layer.
          */
          return new PdfReference(
            (Reference)token,
            file
            );
        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);
View Full Code Here

      file
      );
    PdfDictionary header = getHeader();
    for(Entry<PdfName,PdfDirectObject> entry : file.getTrailer().entrySet())
    {
      PdfName key = entry.getKey();
      if(key.equals(PdfName.Root)
        || key.equals(PdfName.Info)
        || key.equals(PdfName.ID))
      {header.put(key,entry.getValue());}
    }
  }
View Full Code Here

      // Create the font resources collection!
      fonts = new FontResources(scanner.getContents().getDocument());
      resources.setFonts(fonts); resources.update();
    }
    // Get the key associated to the font!
    PdfName name = fonts.getBaseDataObject().getKey(value.getBaseObject());
    // No key found?
    if(name == null)
    {
      // Insert the font within the resources!
      int fontIndex = fonts.size();
      do
      {name = new PdfName(String.valueOf(++fontIndex));}
      while(fonts.containsKey(name));
      fonts.put(name,value); fonts.update();
    }

    return name;
View Full Code Here

      // 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

  {
    if(reference == null)
      return null;

    PdfDictionary dataObject = (PdfDictionary)reference.getDataObject();
    PdfName fieldType = (PdfName)dataObject.get(PdfName.FT);
    PdfInteger fieldFlags = (PdfInteger)dataObject.get(PdfName.Ff);
    int fieldFlagsValue = (fieldFlags == null ? 0 : fieldFlags.getRawValue());
    if(fieldType.equals(PdfName.Btn)) // Button.
    {
      if((fieldFlagsValue & FlagsEnum.Pushbutton.getCode()) > 0) // Pushbutton.
        return new PushButton(reference);
      else if((fieldFlagsValue & FlagsEnum.Radio.getCode()) > 0) // Radio.
        return new RadioButton(reference);
      else // Check box.
        return new CheckBox(reference);
    }
    else if(fieldType.equals(PdfName.Tx)) // Text.
      return new TextField(reference);
    else if(fieldType.equals(PdfName.Ch)) // Choice.
    {
      if((fieldFlagsValue & FlagsEnum.Combo.getCode()) > 0) // Combo box.
        return new ComboBox(reference);
      else // List box.
        return new ListBox(reference);
    }
    else if(fieldType.equals(PdfName.Sig)) // Signature.
      return new SignatureField(reference);
    else // Unknown.
      throw new UnsupportedOperationException("Unknown field type: " + fieldType);
  }
View Full Code Here

  {throw new NotImplementedException();}

  public boolean isChecked(
    )
  {
    PdfName value = (PdfName)getBaseDataObject().get(PdfName.V);

    return !(value == null
      || value.equals(PdfName.Off));
  }
View Full Code Here

  public void setChecked(
    boolean value
    )
  {
    PdfName baseValue = (value ? PdfName.Yes : PdfName.Off);
    getBaseDataObject().put(PdfName.V,baseValue);
    getWidgets().get(0).getBaseDataObject().put(PdfName.AS,baseValue);
  }
View Full Code Here

  @Override
  public void setValue(
    Object value
    )
  {
    PdfName selectedWidgetName = new PdfName((String)value);
    boolean selected = false;
    // Selecting the current appearance state for each widget...
    for(Widget widget : getWidgets())
    {
      PdfName currentState;
      if(((DualWidget)widget).getWidgetName().equals(value)) // Selected state.
      {
        selected = true;
        currentState = selectedWidgetName;
      }
View Full Code Here

      Appearance appearance = widget.getAppearance();
      if(appearance == null)
      {widget.setAppearance(appearance = new Appearance(document));}

      AppearanceStates normalAppearance = appearance.getNormal();
      FormXObject onState = normalAppearance.get(new PdfName(((DualWidget)widget).getWidgetName()));

//TODO:verify!!!
//   appearance.getRollover().put(new PdfName(...),onState);
//   appearance.getDown().put(new PdfName(...),onState);
//   appearance.getRollover().put(PdfName.Off,offState);
View Full Code Here

TOP

Related Classes of org.pdfclown.objects.PdfName

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.