Java Code Examples for org.apache.pdfbox.cos.COSDictionary#getString()

The following examples show how to use org.apache.pdfbox.cos.COSDictionary#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Indicates whether <em>at least one</em> optional content group with this name is enabled.
 * There may be disabled optional content groups with this name even if this function returns
 * true.
 *
 * @param groupName the group name
 * @return true if at least one group is enabled
 */
public boolean isGroupEnabled(String groupName)
{
    boolean result = false;
    COSArray ocgs = getOCGs();
    for (COSBase o : ocgs)
    {
        COSDictionary ocg = toDictionary(o);
        String name = ocg.getString(COSName.NAME);
        if (groupName.equals(name) && isGroupEnabled(new PDOptionalContentGroup(ocg)))
        {
            result = true;
        }
    }
    return result;
}
 
Example 2
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Enables or disables all optional content groups with the given name.
 *
 * @param groupName the group name
 * @param enable true to enable, false to disable
 * @return true if at least one group with this name already had an on or off setting, false
 * otherwise
 */
public boolean setGroupEnabled(String groupName, boolean enable)
{
    boolean result = false;
    COSArray ocgs = getOCGs();
    for (COSBase o : ocgs)
    {
        COSDictionary ocg = toDictionary(o);
        String name = ocg.getString(COSName.NAME);
        if (groupName.equals(name) && setGroupEnabled(new PDOptionalContentGroup(ocg), enable))
        {
            result = true;
        }
    }
    return result;
}
 
Example 3
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Returns the first optional content group of the given name.
 *
 * @param name the group name
 * @return the optional content group or null, if there is no such group
 */
public PDOptionalContentGroup getGroup(String name)
{
    COSArray ocgs = getOCGs();
    for (COSBase o : ocgs)
    {
        COSDictionary ocg = toDictionary(o);
        String groupName = ocg.getString(COSName.NAME);
        if (groupName.equals(name))
        {
            return new PDOptionalContentGroup(ocg);
        }
    }
    return null;
}
 
Example 4
Source File: PDOptionalContentProperties.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Lists all optional content group names.
 * @return an array of all names
 */
public String[] getGroupNames()
{
    COSArray ocgs = (COSArray)dict.getDictionaryObject(COSName.OCGS);
    int size = ocgs.size();
    String[] groups = new String[size];
    for (int i = 0; i < size; i++)
    {
        COSBase obj = ocgs.get(i);
        COSDictionary ocg = toDictionary(obj);
        groups[i] = ocg.getString(COSName.NAME);
    }
    return groups;
}