Java Code Examples for org.apache.pdfbox.cos.COSName#IDENTITY

The following examples show how to use org.apache.pdfbox.cos.COSName#IDENTITY . 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: PDFunction.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Create the correct PD Model function based on the COS base function.
 *
 * @param function The COS function dictionary.
 *
 * @return The PDModel Function object.
 *
 * @throws IOException If we are unable to create the PDFunction object.
 */
public static PDFunction create( COSBase function ) throws IOException
{
    if (function == COSName.IDENTITY)
    {
        return new PDFunctionTypeIdentity(null);
    }
    
    COSBase base = function;
    if (function instanceof COSObject)
    {
        base = ((COSObject) function).getObject();
    }
    if (!(base instanceof COSDictionary))
    {
        throw new IOException("Error: Function must be a Dictionary, but is " +
                base.getClass().getSimpleName());
    }
    COSDictionary functionDictionary = (COSDictionary) base;
    int functionType = functionDictionary.getInt(COSName.FUNCTION_TYPE);
    switch (functionType)
    {
        case 0:
            return new PDFunctionType0(functionDictionary);
        case 2:
            return new PDFunctionType2(functionDictionary);
        case 3:
            return new PDFunctionType3(functionDictionary);
        case 4:
            return new PDFunctionType4(functionDictionary);
        default:
            throw new IOException("Error: Unknown function type " + functionType);
    }
}
 
Example 2
Source File: PDEncryption.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Returns the name of the filter which is used for de/encrypting streams.
 * Default value is "Identity".
 * 
 * @return the name of the filter
 */
public COSName getStreamFilterName() 
{
    COSName stmF = (COSName) dictionary.getDictionaryObject( COSName.STM_F );
    if (stmF == null)
    {
        stmF = COSName.IDENTITY;
    }
    return stmF;
}
 
Example 3
Source File: PDEncryption.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Returns the name of the filter which is used for de/encrypting strings.
 * Default value is "Identity".
 * 
 * @return the name of the filter
 */
public COSName getStringFilterName() 
{
    COSName strF = (COSName) dictionary.getDictionaryObject( COSName.STR_F );
    if (strF == null)
    {
        strF = COSName.IDENTITY;
    }
    return strF;
}