Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSDictionary


     *
     * @return The Actions for this Page
     */
    public PDPageAdditionalActions getActions()
    {
        COSDictionary addAct = (COSDictionary) page.getDictionaryObject(COSName.AA);
        if (addAct == null)
        {
            addAct = new COSDictionary();
            page.setItem(COSName.AA, addAct);
        }
        return new PDPageAdditionalActions(addAct);
    }
View Full Code Here


{
    @Override
    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
                                         COSDictionary parameters, int index) throws IOException
    {
        DecodeResult result = new DecodeResult(new COSDictionary());
        result.getParameters().addAll(parameters);
        BufferedImage image = readJPX(encoded, result);

        WritableRaster raster = image.getRaster();
        if (raster.getDataBuffer().getDataType() != DataBuffer.TYPE_BYTE)
View Full Code Here

            {
                // wrap and rethrow any exceptions
                throw new IOException("Could not read JPEG 2000 (JPX) image", e);
            }

            COSDictionary parameters = result.getParameters();

            // "If the image stream uses the JPXDecode filter, this entry is optional
            // and shall be ignored if present"
            parameters.setInt(COSName.BITS_PER_COMPONENT, image.getColorModel().getComponentSize(0));

            // "Decode shall be ignored, except in the case where the image is treated as a mask"
            if (!parameters.getBoolean(COSName.IMAGE_MASK, false))
            {
                parameters.setItem(COSName.DECODE, null);
            }

            // override dimensions, see PDFBOX-1735
            parameters.setInt(COSName.WIDTH, image.getWidth());
            parameters.setInt(COSName.HEIGHT, image.getHeight());

            // extract embedded color space
            if (!parameters.containsKey(COSName.COLORSPACE))
            {
                result.setColorSpace(new PDJPXColorSpace(image.getColorModel().getColorSpace()));
            }

            return image;
View Full Code Here

     * @throws ValidationException
     */
    protected void checkGraphicState(PreflightContext context, PDPage page, PDShading shadingRes)
            throws ValidationException
            {
        COSDictionary resources = (COSDictionary) shadingRes.getCOSDictionary().getDictionaryObject(
                TRANPARENCY_DICTIONARY_KEY_EXTGSTATE);
        if (resources != null)
        {
            ContextHelper.validateElement(context, resources, EXTGSTATE_PROCESS);
        }
View Full Code Here

    {
        document = new COSDocument();
        document.setHeaderString( "%FDF-1.2" );

        //First we need a trailer
        document.setTrailer( new COSDictionary() );

        //Next we need the root dictionary.
        FDFCatalog catalog = new FDFCatalog();
        setCatalog( catalog );
    }
View Full Code Here

     * @return The documents /Root dictionary
     */
    public FDFCatalog getCatalog()
    {
        FDFCatalog retval = null;
        COSDictionary trailer = document.getTrailer();
        COSDictionary root = (COSDictionary)trailer.getDictionaryObject( COSName.ROOT );
        if( root == null )
        {
            retval = new FDFCatalog();
            setCatalog( retval );
        }
View Full Code Here

     *
     * @param cat The FDF catalog.
     */
    public void setCatalog( FDFCatalog cat )
    {
        COSDictionary trailer = document.getTrailer();
        trailer.setItem( COSName.ROOT, cat );
    }
View Full Code Here

    /**
     * Constructor for subclasses.
     */
    protected PDPropertyList()
    {
        this.dict = new COSDictionary();
    }
View Full Code Here

    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
                                         COSDictionary parameters, int index) throws IOException
    {
        int predictor = -1;

        COSDictionary decodeParams = getDecodeParams(parameters, index);
        if (decodeParams != null)
        {
            predictor = decodeParams.getInt(COSName.PREDICTOR);
        }

        try
        {
            if (predictor > 1)
            {
                int colors = Math.min(decodeParams.getInt(COSName.COLORS, 1), 32);
                int bitsPerPixel = decodeParams.getInt(COSName.BITS_PER_COMPONENT, 8);
                int columns = decodeParams.getInt(COSName.COLUMNS, 1);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                decompress(encoded, baos);
                ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
                Predictor.decodePredictor(predictor, colors, bitsPerPixel, columns, bais, decoded);
                decoded.flush();
View Full Code Here

            List<?> lAnnots = page.getAnnotations();
            for (Object object : lAnnots)
            {
                if (object instanceof PDAnnotation)
                {
                    COSDictionary cosAnnot = ((PDAnnotation) object).getDictionary();
                    ContextHelper.validateElement(context, cosAnnot, ANNOTATIONS_PROCESS);
                }
            }
        }
        catch (IOException e)
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.cos.COSDictionary

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.