Package com.itextpdf.text

Examples of com.itextpdf.text.Rectangle


            }
        }
    }

    private static void moveRectangle(PdfDictionary dic2, PdfReader r, int pageImported, PdfName key, String name) {
        Rectangle m = r.getBoxSize(pageImported, name);
        if (m == null)
            dic2.remove(key);
        else
            dic2.put(key, new PdfRectangle(m));
    }
View Full Code Here


        PageStamp ps = pagesToContent.get(pageN);
        ps.replacePoint = ps.over.getInternalBuffer().size();
    }

    void insertPage(int pageNumber, Rectangle mediabox) {
        Rectangle media = new Rectangle(mediabox);
        int rotation = media.getRotation() % 360;
        PdfDictionary page = new PdfDictionary(PdfName.PAGE);
        PdfDictionary resources = new PdfDictionary();
        PdfArray procset = new PdfArray();
        procset.add(PdfName.PDF);
        procset.add(PdfName.TEXT);
View Full Code Here

                                }
                            }
                        }
                    }
                    if (app != null) {
                        Rectangle box = PdfReader.getNormalizedRectangle(merged.getAsArray(PdfName.RECT));
                        PdfContentByte cb = getOverContent(page);
                        cb.setLiteral("Q ");
                        cb.addTemplate(app, box.getLeft(), box.getBottom());
                        cb.setLiteral("q ");
                    }
                }
                if (partialFlattening.isEmpty())
                    continue;
View Full Code Here

              }
            }
          }
          if (app != null)
          {
            Rectangle box = PdfReader.getNormalizedRectangle(annDic.getAsArray(PdfName.RECT));
            PdfContentByte cb = getOverContent(page);
            cb.setLiteral("Q ");
            cb.addTemplate(app, box.getLeft(), box.getBottom());
            cb.setLiteral("q ");
          }
        }
      }
      for (int idx = 0; idx < annots.size(); ++idx)
View Full Code Here

                    markUsed(annots);
                    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.top(),
                                    rect.right(),
                                    pageSize.getTop() - rect.bottom(),
                                    rect.left()));
                                    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

    private void addPageSizeEnforcer(PdfWriter writer) {
        if (marginEnforcerImage == null) {
            marginEnforcerImage = createEnforcerImage();
        }
        PdfContentByte cb = writer.getDirectContent();
        Rectangle pageSize = writer.getPageSize();
        try {
            float sz = 2.5f;
            float dx = pageSize.getWidth() - sz;
            float dy = pageSize.getHeight() - sz;
            cb.addImage(marginEnforcerImage, sz, 0, 0, sz, 0, dy);
            cb.addImage(marginEnforcerImage, 0, sz, -sz, 0, sz, 0);
            cb.addImage(marginEnforcerImage, -sz, 0, 0, -sz, dx + sz, sz);
            cb.addImage(marginEnforcerImage, 0, -sz, sz, 0, dx, dy + sz);
        } catch (DocumentException ex) {
View Full Code Here

            // we create a reader for a certain document
            PdfReader reader = new PdfReader(src.getAbsolutePath());
            // we retrieve the total number of pages and the page size
            int total = reader.getNumberOfPages();
            System.out.println("There are " + total + " pages in the original file.");
            Rectangle pageSize = reader.getPageSize(1);
            Rectangle newSize = new Rectangle(pageSize.getWidth()*2, pageSize.getHeight());
            // step 1: creation of a document-object
            Document document = new Document(newSize, 0, 0, 0, 0);
            // step 2: we create a writer that listens to the document
            ByteArrayOutputStream tmp = new ByteArrayOutputStream();
            PdfWriter writer = PdfWriter.getInstance(document, tmp);
View Full Code Here

        backgr.setColorFill(background);
        backgr.rectangle(left, bottom, right - left, top - bottom);
        backgr.fill();
      }
      if (cell.hasBorders()) {
        Rectangle newRect = new Rectangle(left, bottom, right, top);
        // Clone non-position parameters except for the background color
        newRect.cloneNonPositionParameters(cell);
        newRect.setBackgroundColor(null);
        // Write the borders on the line canvas
        PdfContentByte lineCanvas = canvases[PdfPTable.LINECANVAS];
        lineCanvas.rectangle(newRect);
      }
    }
View Full Code Here

                    }
                }
            }
      PdfPCellEvent evt = cell.getCellEvent();
      if (evt != null) {
        Rectangle rect = new Rectangle(cell.getLeft() + xPos, cell.getTop()
            + yPos - currentMaxHeight, cell.getRight() + xPos, cell.getTop()
            + yPos);
        evt.cellLayout(cell, rect, canvases);
      }
    }
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

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.