Package org.pdfbox.pdmodel.common

Examples of org.pdfbox.pdmodel.common.PDRectangle


     * @param pdfPage The page to draw.
     */
    public void setPage( PDPage pdfPage )
    {
        page = pdfPage;
        PDRectangle pageSize = page.findMediaBox();
        int rotation = page.findRotation();
        pageDimension = pageSize.createDimension();
        if( rotation == 90 || rotation == 270 )
        {
            pageDimension = new Dimension( pageDimension.height, pageDimension.width );
        }
        setSize( pageDimension );
View Full Code Here


     * {@inheritDoc}
     */
    public PageFormat getPageFormat(int pageIndex)
    {
        PDPage page = (PDPage)getDocumentCatalog().getAllPages().get( pageIndex );
        PDRectangle mediaBox = page.findMediaBox();
        PageFormat format = new PageFormat();
        Paper paper = new Paper();
        //hmm the imageable area might need to be the CropBox instead
        //of the media box???
        double width=mediaBox.getWidth();
        double height=mediaBox.getHeight();
        if( width > height )
        {
            format.setOrientation( PageFormat.LANDSCAPE );
            width=mediaBox.getHeight();
            height=mediaBox.getWidth();
        }
        paper.setImageableArea( 0,0,width,height);
        paper.setSize( width, height );
        format.setPaper( paper );
        return format;
View Full Code Here

     *
     * @return The bounding box for this appearance.
     */
    public PDRectangle getBoundingBox()
    {
        PDRectangle box = null;
        COSArray bbox = (COSArray)stream.getDictionaryObject( COSName.getPDFName( "BBox" ) );
        if( bbox != null )
        {
            box = new PDRectangle( bbox );
        }
        return box;
    }
View Full Code Here

    public PDRectangle getRectDifference()
    {
        COSArray rd = (COSArray) getDictionary().getDictionaryObject( "RD" );
        if (rd != null)
        {
            return new PDRectangle( rd );
        }
        else
        {
            return null;
        }
View Full Code Here

    private static List extractAnnotations(final PDPage page, final PDFTextStripperByArea stripper, final List linkAnnotations, final List linkRegions) throws IOException {
      final List annotations = page.getAnnotations();
        for (int j = 0; j < annotations.size(); j++) {
          final PDAnnotation annot = (PDAnnotation) annotations.get(j);
            if (annot instanceof PDAnnotationLink) {
              final PDRectangle rect = annot.getRectangle();
                //need to reposition link rectangle to match text space plus add
                //a little to account for descenders and the like
              final float x = rect.getLowerLeftX() - 1;
                float y = rect.getUpperRightY() - 1;
                final float width = rect.getWidth() + 2;
                final float height = rect.getHeight() + rect.getHeight() / 4;
                final int rotation = page.findRotation();
                if (rotation == 0) {
                  final PDRectangle pageSize = page.findMediaBox();
                    y = pageSize.getHeight() - y;
                }

                final Rectangle2D.Float awtRect = new Rectangle2D.Float(x, y, width, height);
                stripper.addRegion(Integer.toString(j), awtRect);
                linkAnnotations.add(annot);
View Full Code Here

    private void init(PDDocument doc) throws ParserException
    {
        List pages = doc.getDocumentCatalog().getAllPages();
        if (pages != null)
        {
            PDRectangle mediaBox = null;
            this.page = (PDPage) pages.get(0);
            mediaBox = page.getMediaBox();
            if (mediaBox != null)
            {
                this.width = mediaBox.getWidth();
                this.height = mediaBox.getHeight();
            }
            else
            {
                throw new ParserException();
            }
View Full Code Here

     * @return The Rect value of this annotation.
     */
    public PDRectangle getRectangle()
    {
        COSArray rectArray = (COSArray)dictionary.getDictionaryObject( COSName.getPDFName( "Rect" ) );
        return new PDRectangle( rectArray );
    }
View Full Code Here

     *
     * @return The MediaBox at this level in the hierarchy.
     */
    public PDRectangle getMediaBox()
    {
        PDRectangle retval = null;
        COSArray array = (COSArray)page.getDictionaryObject( COSName.getPDFName( "MediaBox" ) );
        if( array != null )
        {
            retval = new PDRectangle( array );
        }
        return retval;
    }
View Full Code Here

     *
     * @return The MediaBox at this level in the hierarchy.
     */
    public PDRectangle findMediaBox()
    {
        PDRectangle retval = getMediaBox();
        PDPageNode parent = getParent();
        if( retval == null && parent != null )
        {
            retval = parent.findMediaBox();
        }
View Full Code Here

     *
     * @return The CropBox at this level in the hierarchy.
     */
    public PDRectangle getCropBox()
    {
        PDRectangle retval = null;
        COSArray array = (COSArray)page.getDictionaryObject( COSName.getPDFName( "CropBox" ) );
        if( array != null )
        {
            retval = new PDRectangle( array );
        }
        return retval;
    }
View Full Code Here

TOP

Related Classes of org.pdfbox.pdmodel.common.PDRectangle

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.