Package com.itextpdf.text

Examples of com.itextpdf.text.Rectangle


    public static Rectangle getNormalizedRectangle(final PdfArray box) {
        float llx = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(0))).floatValue();
        float lly = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(1))).floatValue();
        float urx = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(2))).floatValue();
        float ury = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(3))).floatValue();
        return new Rectangle(Math.min(llx, urx), Math.min(lly, ury),
        Math.max(llx, urx), Math.max(lly, ury));
    }
View Full Code Here


        }

        void applyRotation(PdfDictionary pageN, ByteBuffer out) {
            if (!cstp.rotateContents)
                return;
            Rectangle page = reader.getPageSizeWithRotation(pageN);
            int rotation = page.getRotation();
            switch (rotation) {
                case 90:
                    out.append(PdfContents.ROTATE90);
                    out.append(page.getTop());
                    out.append(' ').append('0').append(PdfContents.ROTATEFINAL);
                    break;
                case 180:
                    out.append(PdfContents.ROTATE180);
                    out.append(page.getRight());
                    out.append(' ');
                    out.append(page.getTop());
                    out.append(PdfContents.ROTATEFINAL);
                    break;
                case 270:
                    out.append(PdfContents.ROTATE270);
                    out.append('0').append(' ');
                    out.append(page.getRight());
                    out.append(PdfContents.ROTATEFINAL);
                    break;
            }
        }
View Full Code Here

                        annots.add(annot.getIndirectReference());
                        if (!annot.isUsed()) {
                            PdfRectangle rect = (PdfRectangle)annot.get(PdfName.RECT);
                            if (rect != null && (rect.left() != 0 || rect.right() != 0 || rect.top() != 0 || rect.bottom() != 0)) {
                                int rotation = reader.getPageRotation(pageN);
                                Rectangle pageSize = reader.getPageSizeWithRotation(pageN);
                                switch (rotation) {
                                    case 90:
                                        annot.put(PdfName.RECT, new PdfRectangle(
                                        pageSize.getTop() - rect.bottom(),
                                        rect.left(),
                                        pageSize.getTop() - rect.top(),
                                        rect.right()));
                                        break;
                                    case 180:
                                        annot.put(PdfName.RECT, new PdfRectangle(
                                        pageSize.getRight() - rect.left(),
                                        pageSize.getTop() - rect.bottom(),
                                        pageSize.getRight() - rect.right(),
                                        pageSize.getTop() - rect.top()));
                                        break;
                                    case 270:
                                        annot.put(PdfName.RECT, new PdfRectangle(
                                        rect.bottom(),
                                        pageSize.getRight() - rect.left(),
                                        rect.top(),
                                        pageSize.getRight() - rect.right()));
                                        break;
                                }
                            }
                        }
                    }
View Full Code Here

 
  public void open(String filename, String pagesize) throws Exception {
    open(filename, pagesize, 72,72,72,72);
  }
  public void open(String filename, String pagesize, float left, float right, float top, float bottom) throws Exception {
    Rectangle psize = PageSize.A4;
    if ("A5".equals(pagesize)) psize = PageSize.A5;
    if ("A3".equals(pagesize)) psize = PageSize.A3;
    doc = new Document(psize);
    doc.setMargins(left, right, top, bottom); // left, right, top, bottom
    writer = PdfWriter.getInstance(doc, new FileOutputStream(filename));
View Full Code Here

    public void onStartPage(PdfWriter writer, Document document) {

      try {

        Rectangle page = document.getPageSize();

        PdfPCell imageCell = null;
        PdfPCell textCell = null;

        PdfPTable head = new PdfPTable(2);
        float[] widths = new float[] { 1f, 4f };
        head.setWidths(widths);
        ServletContext context = getServletContext();
       
        String relativeWebPath = "/images/logo_melon.gif";
        String absoluteDiskPath = context.getRealPath(relativeWebPath);
        Image headImage = Image.getInstance(absoluteDiskPath);
        headImage.scaleToFit(75, 75);

        imageCell = new PdfPCell(headImage);
        imageCell.setBorder(Rectangle.NO_BORDER);
        head.addCell(imageCell);

        Font catFont = new Font(Font.FontFamily.HELVETICA, 16,
            Font.BOLD);
        textCell = new PdfPCell(new Phrase("Reporte de Novedades: "
            + negocio, catFont));
        textCell.setBorder(Rectangle.NO_BORDER);
        head.addCell(textCell);

        head.setTotalWidth(page.getWidth() - document.leftMargin()
            - document.rightMargin());

        head.writeSelectedRows(
            0,
            -1,
            document.leftMargin(),
            page.getHeight() - document.topMargin()
                + head.getTotalHeight(),
            writer.getDirectContent());
        document.add(new Paragraph("\n"));

      } catch (Exception de) {
View Full Code Here

        public void onStartPage(PdfWriter writer, Document document) {

            try {
       
                Rectangle page = document.getPageSize();

                PdfPCell imageCell = null;
                PdfPCell textCell = null;

                PdfPTable head = new PdfPTable(2);
                float[] widths = new float[] { 1f, 4f };
                head.setWidths(widths);

            ServletContext context = ServletActionContext.getServletContext();
        String relativeWebPath = "/images/logo_melon.gif";
        String absoluteDiskPath = context.getRealPath(relativeWebPath);
        Image headImage = Image.getInstance(absoluteDiskPath);
        headImage.scaleToFit(75, 75);
       
                imageCell = new PdfPCell(headImage);
                imageCell.setBorder(Rectangle.NO_BORDER);
                head.addCell(imageCell);

                Font catFont = new Font(Font.FontFamily.HELVETICA, 16,
                  Font.BOLD);
                textCell = new PdfPCell(new Phrase("Reporte de Novedades: " + negocio,catFont));
                textCell.setBorder(Rectangle.NO_BORDER);
                head.addCell(textCell);

                head.setTotalWidth(page.getWidth() - document.leftMargin()
                                - document.rightMargin());

                head.writeSelectedRows(0, -1, document.leftMargin(), page
                                .getHeight()
                                - document.topMargin() + head.getTotalHeight(), writer
                                .getDirectContent())
                document.add(new Paragraph("\n"));
View Full Code Here

                break;
            case 270:
                app.setMatrix(0, -1, 1, 0, 0, box.getWidth());
                break;
        }
        Rectangle box = new Rectangle(app.getBoundingBox());
        float cx = box.getWidth() / 2;
        float cy = box.getHeight() / 2;
        float r = (Math.min(box.getWidth(), box.getHeight()) - borderWidth) / 2;
        if (r <= 0)
            return app;
        if (backgroundColor != null) {
            app.setColorFill(backgroundColor);
            app.circle(cx, cy, r + borderWidth / 2);
View Full Code Here

     * Gets the rotated page from a page dictionary.
     * @param page the page dictionary
     * @return the rotated page
     */
    public Rectangle getPageSizeWithRotation(final PdfDictionary page) {
        Rectangle rect = getPageSize(page);
        int rotation = getPageRotation(page);
        while (rotation > 0) {
            rect = rect.rotate();
            rotation -= 90;
        }
        return rect;
    }
View Full Code Here

    public static Rectangle getNormalizedRectangle(final PdfArray box) {
        float llx = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(0))).floatValue();
        float lly = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(1))).floatValue();
        float urx = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(2))).floatValue();
        float ury = ((PdfNumber)getPdfObjectRelease(box.getPdfObject(3))).floatValue();
        return new Rectangle(Math.min(llx, urx), Math.min(lly, ury),
        Math.max(llx, urx), Math.max(lly, ury));
    }
View Full Code Here

        }

        void applyRotation(PdfDictionary pageN, ByteBuffer out) {
            if (!cstp.rotateContents)
                return;
            Rectangle page = reader.getPageSizeWithRotation(pageN);
            int rotation = page.getRotation();
            switch (rotation) {
                case 90:
                    out.append(PdfContents.ROTATE90);
                    out.append(page.getTop());
                    out.append(' ').append('0').append(PdfContents.ROTATEFINAL);
                    break;
                case 180:
                    out.append(PdfContents.ROTATE180);
                    out.append(page.getRight());
                    out.append(' ');
                    out.append(page.getTop());
                    out.append(PdfContents.ROTATEFINAL);
                    break;
                case 270:
                    out.append(PdfContents.ROTATE270);
                    out.append('0').append(' ');
                    out.append(page.getRight());
                    out.append(PdfContents.ROTATEFINAL);
                    break;
            }
        }
View Full Code Here

TOP

Related Classes of com.itextpdf.text.Rectangle

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.