Package com.lowagie.text

Examples of com.lowagie.text.LwgRectangle


        urx = x;
        ury = y;
      }

      public PdfAnnotation createAnnotation(PdfWriter writer) {
        PdfAnnotation annotation = new PdfAnnotation(writer, new LwgRectangle(llx, lly, urx, ury));
        if (newPage != 0) {
              PdfIndirectReference ref = writer.getPageReference(newPage);
              destination.set(0, ref);
        }
        if (destination != null) annotation.put(PdfName.DEST, destination);
View Full Code Here


        }
       
        void applyRotation(PdfDictionary pageN, ByteBuffer out) {
            if (!cstp.rotateContents)
                return;
            LwgRectangle 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);
                                LwgRectangle 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

            urx = Math.max(urx, r[k]);
            ury = Math.max(ury, r[k + 1]);
         }
         annot = new Annotation(annot);
         annot.setDimensions(llx, lly, urx, ury);
         PdfAnnotation an = PdfAnnotationsImp.convertAnnotation(writer, annot, new LwgRectangle(llx, lly, urx, ury));
         if (an == null)
            return;
         addAnnotation(an);
      }
      catch (Exception ee)
View Full Code Here

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

    public static LwgRectangle getNormalizedRectangle(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 LwgRectangle(Math.min(llx, urx), Math.min(lly, ury),
        Math.max(llx, urx), Math.max(lly, ury));
    }
View Full Code Here

      // step4
     
      // page 1
          LwgFont tableFont = FontFactory.getFont("Helvetica", 8, LwgFont.BOLD, Color.BLACK);
          float padding = 0f;
          LwgRectangle border = new LwgRectangle(0f, 0f);
          border.setBorderWidthLeft(6f);
          border.setBorderWidthBottom(5f);
          border.setBorderWidthRight(4f);
          border.setBorderWidthTop(2f);
          border.setBorderColorLeft(Color.RED);
          border.setBorderColorBottom(Color.ORANGE);
          border.setBorderColorRight(Color.YELLOW);
          border.setBorderColorTop(Color.GREEN);
          makeTestPage(tableFont, border, writer, document, padding, true, true);
          LwgFont font = FontFactory.getFont("Helvetica", 10);
          Paragraph p;
          p = new Paragraph("\nVarious border widths and colors\nuseAscender=true, useDescender=true", font);
          document.add(p);
         
          document.newPage();
         
          // page 2
          padding = 2f;
          border = new LwgRectangle(0f, 0f);
          border.setBorderWidthLeft(1f);
          border.setBorderWidthBottom(2f);
          border.setBorderWidthRight(1f);
          border.setBorderWidthTop(2f);
          border.setBorderColor(Color.BLACK);
          makeTestPage(tableFont, border, writer, document, padding, true, true);
          p = new Paragraph("More typical use - padding of 2\nuseBorderPadding=true, useAscender=true, useDescender=true", font);
          document.add(p);
         
          document.newPage();
         
          // page 3
          padding = 0f;
          border = new LwgRectangle(0f, 0f);
          border.setBorderWidthLeft(1f);
          border.setBorderWidthBottom(2f);
          border.setBorderWidthRight(1f);
          border.setBorderWidthTop(2f);
          border.setBorderColor(Color.BLACK);
          makeTestPage(tableFont, border, writer, document, padding, false, true);
          p = new Paragraph("\nuseBorderPadding=true, useAscender=false, useDescender=true", font);
          document.add(p);
         
          document.newPage();
         
          // page 4
          padding = 0f;
          border = new LwgRectangle(0f, 0f);
          border.setBorderWidthLeft(1f);
          border.setBorderWidthBottom(2f);
          border.setBorderWidthRight(1f);
          border.setBorderWidthTop(2f);
          border.setBorderColor(Color.BLACK);
          makeTestPage(tableFont, border, writer, document, padding, false, false);
          p = new Paragraph("\nuseBorderPadding=true, useAscender=false, useDescender=false", font);
          document.add(p);
         
          document.newPage();
         
          // page 5
          padding = 0f;
          border = new LwgRectangle(0f, 0f);
          border.setBorderWidthLeft(1f);
          border.setBorderWidthBottom(2f);
          border.setBorderWidthRight(1f);
          border.setBorderWidthTop(2f);
          border.setBorderColor(Color.BLACK);
          makeTestPage(tableFont, border, writer, document, padding, true, false);
          p = new Paragraph("\nuseBorderPadding=true, useAscender=true, useDescender=false", font);
          document.add(p);
    } catch (Exception de) {
      de.printStackTrace();
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgRectangle

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.