Tabnine Logo
PDAppearanceEntry
Code IndexAdd Tabnine to your IDE (free)

How to use
PDAppearanceEntry
in
org.apache.pdfbox.pdmodel.interactive.annotation

Best Java code snippets using org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry (Showing top 20 results out of 315)

origin: apache/pdfbox

/**
 * Get the annotations normal appearance.
 * 
 * <p>
 * This will get the annotations normal appearance. If this is not existent
 * an empty appearance entry will be created.
 * 
 * @return the appearance entry representing the normal appearance.
 */
private PDAppearanceEntry getNormalAppearance()
{
  PDAppearanceDictionary appearanceDictionary = getAppearance();
  PDAppearanceEntry normalAppearanceEntry = appearanceDictionary.getNormalAppearance();
  if (normalAppearanceEntry.isSubDictionary())
  {
    //TODO replace with "document.getDocument().createCOSStream()" 
    normalAppearanceEntry = new PDAppearanceEntry(new COSStream());
    appearanceDictionary.setNormalAppearance(normalAppearanceEntry);
  }
  return normalAppearanceEntry;
}

origin: apache/pdfbox

/**
 * Returns the appearance stream for this annotation, if any. The annotation state is taken into account, if
 * present.
 */
public PDAppearanceStream getNormalAppearanceStream()
{
  PDAppearanceDictionary appearanceDict = getAppearance();
  if (appearanceDict == null)
  {
    return null;
  }
  PDAppearanceEntry normalAppearance = appearanceDict.getNormalAppearance();
  if (normalAppearance == null)
  {
    return null;
  }
  if (normalAppearance.isSubDictionary())
  {
    COSName state = getAppearanceState();
    return normalAppearance.getSubDictionary().get(state);
  }
  else
  {
    return normalAppearance.getAppearanceStream();
  }
}
origin: apache/pdfbox

/**
 * Returns the entry as an appearance stream.
 *
 * @throws IllegalStateException if this entry is not an appearance stream
 */
public PDAppearanceStream getAppearanceStream()
{
  if (!isStream())
  {
    throw new IllegalStateException("This entry is not an appearance stream");
  }
  return new PDAppearanceStream((COSStream) entry);
}
origin: org.verapdf/pdfbox-validation-model

private void addContentStreamsFromAppearanceEntry(COSBase appearanceEntry, List<PDContentStream> appearances) {
  if (appearanceEntry != null) {
    PDAppearanceEntry newAppearance = new PDAppearanceEntry(appearanceEntry);
    if (newAppearance.isStream()) {
      addAppearance(appearances, newAppearance.getAppearanceStream());
    } else {
      Map<COSName, PDAppearanceStream> subDictionary = newAppearance.getSubDictionary();
      for (PDAppearanceStream stream : subDictionary.values()) {
        addAppearance(appearances, stream);
      }
    }
  }
}
origin: org.verapdf/pdfbox-feature-reporting

private Set<String> getAppearanceEntryDependencies(PDAppearanceEntry entry, COSBase entryLink) {
  Set<String> res = new HashSet<>();
  if (entry.isStream()) {
    res.add(getAppearanceStreamDependencies(entry.getAppearanceStream(), entryLink));
  } else {
    for (Map.Entry<COSName, PDAppearanceStream> mapEntry : entry.getSubDictionary().entrySet()) {
      res.add(getAppearanceStreamDependencies(mapEntry.getValue(),
          ((COSDictionary) entry.getCOSObject()).getItem(mapEntry.getKey())));
    }
  }
  return res;
}
origin: org.verapdf/pdfbox-validation-model

private static void addAllAppearances(PDAppearanceEntry appearance, List<PDAppearanceStream> list) {
  if (appearance == null) {
    return;
  }
  if (appearance.isStream()) {
    PDAppearanceStream appearanceStream = appearance.getAppearanceStream();
    if (appearanceStream != null) {
      list.add(appearanceStream);
    }
  } else {
    for (PDAppearanceStream appearanceStream : appearance.getSubDictionary().values()) {
      if (appearanceStream != null) {
        list.add(appearanceStream);
      }
    }
  }
}
origin: apache/pdfbox

if (appearance != null && appearance.isStream())
  appearanceStream = appearance.getAppearanceStream();
origin: apache/pdfbox

/**
 * This will return a list of appearances. In the case where there is only one appearance the map will contain one
 * entry whose key is the string "default".
 *
 * @return A list of key(java.lang.String) value(PDAppearanceStream) pairs
 */
public PDAppearanceEntry getNormalAppearance()
{
  COSBase entry = dictionary.getDictionaryObject(COSName.N);
  if (entry instanceof COSDictionary)
  {
    return new PDAppearanceEntry((COSDictionary) entry);
  }
  return null;
}
origin: apache/pdfbox

private String getOnValueForWidget(PDAnnotationWidget widget)
{
  PDAppearanceDictionary apDictionary = widget.getAppearance();
  if (apDictionary != null) 
  {
    PDAppearanceEntry normalAppearance = apDictionary.getNormalAppearance();
    if (normalAppearance != null)
    {
      Set<COSName> entries = normalAppearance.getSubDictionary().keySet();
      for (COSName entry : entries)
      {
        if (COSName.Off.compareTo(entry) != 0)
        {
          return entry.getName();
        }
      }
    }
  }
  return "";
}

origin: apache/pdfbox

private void updateByValue(String value)
{
  getCOSObject().setName(COSName.V, value);
  // update the appearance state (AS)
  for (PDAnnotationWidget widget : getWidgets())
  {
    if (widget.getAppearance() == null)
    {
      continue;
    }
    PDAppearanceEntry appearanceEntry = widget.getAppearance().getNormalAppearance();
    if (((COSDictionary) appearanceEntry.getCOSObject()).containsKey(value))
    {
      widget.setAppearanceState(value);
    }
    else
    {
      widget.setAppearanceState(COSName.Off.getName());
    }
  }
}
origin: apache/pdfbox

private PDAppearanceContentStream getAppearanceEntryAsContentStream(
     PDAppearanceEntry appearanceEntry, boolean compress) throws IOException
{
  PDAppearanceStream appearanceStream = appearanceEntry.getAppearanceStream();
  setTransformationMatrix(appearanceStream);
  // ensure there are resources
  PDResources resources = appearanceStream.getResources();
  if (resources == null)
  {
    resources = new PDResources();
    appearanceStream.setResources(resources);
  }
  return new PDAppearanceContentStream(appearanceStream, compress);
}

origin: apache/pdfbox

  /**
   * Returns the entry as an appearance subdictionary.
   *
   * @throws IllegalStateException if this entry is not an appearance subdictionary
   */
  public Map<COSName, PDAppearanceStream> getSubDictionary()
  {
    if (!isSubDictionary())
    {
      throw new IllegalStateException("This entry is not an appearance subdictionary");
    }

    COSDictionary dict = entry;
    Map<COSName, PDAppearanceStream> map = new HashMap<>();

    for (COSName name : dict.keySet())
    {
      COSBase value = dict.getDictionaryObject(name);

      // the file from PDFBOX-1599 contains /null as its entry, so we skip non-stream entries
      if (value instanceof COSStream)
      {
        map.put(name, new PDAppearanceStream((COSStream) value));
      }
    }

    return new COSDictionaryMap<>(map, dict);
  }
}
origin: org.apache.pdfbox/pdfbox

if (appearance != null && appearance.isStream())
  appearanceStream = appearance.getAppearanceStream();
origin: apache/pdfbox

/**
 * This will return a list of appearances. In the case where there is only one appearance the map will contain one
 * entry whose key is the string "default". If there is no rollover appearance then the normal appearance will be
 * returned. Which means that this method will never return null.
 *
 * @return A list of key(java.lang.String) value(PDAppearanceStream) pairs
 */
public PDAppearanceEntry getDownAppearance()
{
  COSBase entry = dictionary.getDictionaryObject(COSName.D);
  if (entry instanceof COSDictionary)
  {
    return new PDAppearanceEntry((COSDictionary) entry);
  }
  else
  {
    return getNormalAppearance();
  }
}
origin: apache/pdfbox

if (normalAppearance != null)
  Set<COSName> entries = normalAppearance.getSubDictionary().keySet();
  for (COSName entry : entries)
origin: apache/pdfbox

PDAppearanceEntry normalAppearance = ap.getNormalAppearance();
COSDictionary normalAppearanceDict = (COSDictionary) normalAppearance.getCOSObject();
normalAppearanceDict.setItem(COSName.Off, createRadioButtonAppearanceStream(document, widget, false));
normalAppearanceDict.setItem(COSName.YES, createRadioButtonAppearanceStream(document, widget, true));
origin: com.github.lafa.pdfbox/pdfbox

private PDAppearanceContentStream getAppearanceEntryAsContentStream(PDAppearanceEntry appearanceEntry) throws IOException
{
  PDAppearanceStream appearanceStream = appearanceEntry.getAppearanceStream();
  setTransformationMatrix(appearanceStream);
  return new PDAppearanceContentStream(appearanceStream);
}

origin: org.verapdf/pdfbox-validation-model

private static String getN_type(PDAnnotation annot) {
  PDAppearanceDictionary appearanceDictionary = annot.getAppearance();
  if (appearanceDictionary != null) {
    PDAppearanceEntry normalAppearance = appearanceDictionary.getNormalAppearance();
    if (normalAppearance == null) {
      return null;
    } else if (normalAppearance.isSubDictionary()) {
      return DICT;
    } else {
      return STREAM;
    }
  }
  return null;
}
origin: org.apache.pdfbox/pdfbox

/**
 * Returns the appearance stream for this annotation, if any. The annotation state is taken into account, if
 * present.
 */
public PDAppearanceStream getNormalAppearanceStream()
{
  PDAppearanceDictionary appearanceDict = getAppearance();
  if (appearanceDict == null)
  {
    return null;
  }
  PDAppearanceEntry normalAppearance = appearanceDict.getNormalAppearance();
  if (normalAppearance == null)
  {
    return null;
  }
  if (normalAppearance.isSubDictionary())
  {
    COSName state = getAppearanceState();
    return normalAppearance.getSubDictionary().get(state);
  }
  else
  {
    return normalAppearance.getAppearanceStream();
  }
}
origin: apache/pdfbox

/**
 * Get the annotations down appearance.
 * 
 * <p>
 * This will get the annotations down appearance. If this is not existent an
 * empty appearance entry will be created.
 * 
 * @return the appearance entry representing the down appearance.
 */
PDAppearanceEntry getDownAppearance()
{
  PDAppearanceDictionary appearanceDictionary = getAppearance();
  PDAppearanceEntry downAppearanceEntry = appearanceDictionary.getDownAppearance();
  if (downAppearanceEntry.isSubDictionary())
  {
    //TODO replace with "document.getDocument().createCOSStream()" 
    downAppearanceEntry = new PDAppearanceEntry(new COSStream());
    appearanceDictionary.setDownAppearance(downAppearanceEntry);
  }
  return downAppearanceEntry;
}
org.apache.pdfbox.pdmodel.interactive.annotationPDAppearanceEntry

Javadoc

An entry in an appearance dictionary. May contain either a single appearance stream or an appearance subdictionary.

Most used methods

  • <init>
    Constructor for reading.
  • getAppearanceStream
    Returns the entry as an appearance stream.
  • getCOSObject
  • getSubDictionary
    Returns the entry as an appearance subdictionary.
  • isStream
    Returns true if this entry is an appearance stream.
  • isSubDictionary
    Returns true if this entry is an appearance subdictionary.

Popular in Java

  • Running tasks concurrently on multiple threads
  • getContentResolver (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • compareTo (BigDecimal)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • JOptionPane (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now