當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle.getLeft方法代碼示例

本文整理匯總了Java中com.itextpdf.text.Rectangle.getLeft方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.getLeft方法的具體用法?Java Rectangle.getLeft怎麽用?Java Rectangle.getLeft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.itextpdf.text.Rectangle的用法示例。


在下文中一共展示了Rectangle.getLeft方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cellLayout

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
@Override
    public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) {
        PdfContentByte canvas = canvases[PdfPTable.BACKGROUNDCANVAS];

        float xTransition = position.getLeft() + (position.getRight() - position.getLeft()) * (percent/100.0f);
        float yTransition = (position.getTop() + position.getBottom()) / 2f;
        float radius = (position.getRight() - position.getLeft()) * 0.025f;
        PdfShading axial = PdfShading.simpleAxial(canvas.getPdfWriter(),
                xTransition - radius, yTransition, xTransition + radius, yTransition, leftColor, rightColor);
        PdfShadingPattern shading = new PdfShadingPattern(axial);

        canvas.saveState();
        canvas.setShadingFill(shading);
        canvas.rectangle(position.getLeft(), position.getBottom(), position.getWidth(), position.getHeight());
//        canvas.clip();
        canvas.fill();
        canvas.restoreState();
    }
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:19,代碼來源:PercentileCellBackground.java

示例2: cellLayout

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
public void cellLayout(PdfPCell cell, Rectangle position,
                               PdfContentByte[] canvases) {
            PdfWriter writer = canvases[0].getPdfWriter();
            float x = position.getLeft();
            float y = position.getBottom();
            Rectangle rect = new Rectangle(x-5, y-5, x+5, y+5);
            RadioCheckField checkbox = new RadioCheckField(
                    writer, rect, name, "Yes");
            checkbox.setCheckType(RadioCheckField.TYPE_CROSS);
            checkbox.setChecked(check);
// change: set border color
            checkbox.setBorderColor(BaseColor.BLACK);

            try {
                pdfStamper.addAnnotation(checkbox.getCheckField(), page);
            } catch (Exception e) {
                throw new ExceptionConverter(e);
            }
        }
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:20,代碼來源:AddField.java

示例3: testSplitDocumentA6

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
/**
 * <a href="https://stackoverflow.com/questions/46466747/how-to-split-a-pdf-page-in-java">
 * How to split a PDF page in java?
 * </a>
 * <p>
 * This test shows how to split the pages of a document into tiles of A6
 * size using the {@link Abstract2DPdfPageSplittingTool}.
 * </p>
 */
@Test
public void testSplitDocumentA6() throws IOException, DocumentException {
    try (InputStream resource = getClass().getResourceAsStream("document.pdf");
            OutputStream result = new FileOutputStream(new File(RESULT_FOLDER, "document-A6.pdf"))) {
        Abstract2DPdfPageSplittingTool tool = new Abstract2DPdfPageSplittingTool() {
            @Override
            protected Iterable<Rectangle> determineSplitRectangles(PdfReader reader, int page) {
                Rectangle targetSize = PageSize.A6;
                List<Rectangle> rectangles = new ArrayList<>();
                Rectangle pageSize = reader.getPageSize(page);
                for (float y = pageSize.getTop(); y > pageSize.getBottom() + 5; y-=targetSize.getHeight()) {
                    for (float x = pageSize.getLeft(); x < pageSize.getRight() - 5; x+=targetSize.getWidth()) {
                        rectangles.add(new Rectangle(x, y - targetSize.getHeight(), x + targetSize.getWidth(), y));
                    }
                }
                return rectangles;
            }
        };
        tool.split(result, new PdfReader(resource));
    }
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:31,代碼來源:SplitPages.java

示例4: headerText

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private void headerText(PdfWriter writer, Rectangle rect)
{
    float center = (rect.getLeft() + rect.getRight()) / 2;

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("Header Text"), center, rect.getTop(), 0);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase("01.01.1970"), center, rect.getTop() - 16,
            0);
}
 
開發者ID:wolfposd,項目名稱:IMSQTI2PDF,代碼行數:11,代碼來源:HeaderFooter.java

示例5: getVertices

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
private Point2D[] getVertices(Rectangle rect) {
    Point2D[] points = {
            new Point2D.Double(rect.getLeft(), rect.getBottom()),
            new Point2D.Double(rect.getRight(), rect.getBottom()),
            new Point2D.Double(rect.getRight(), rect.getTop()),
            new Point2D.Double(rect.getLeft(), rect.getTop())
    };

    return points;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:11,代碼來源:PdfCleanUpRegionFilter.java

示例6: allowText

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
/**
 * Checks if the text is COMPLETELY inside render filter region.
 */
@Override
public boolean allowText(TextRenderInfo renderInfo) {
    LineSegment ascent = renderInfo.getAscentLine();
    LineSegment descent = renderInfo.getDescentLine();

    Point2D[] glyphRect = new Point2D[] {
            new Point2D.Float(ascent.getStartPoint().get(0), ascent.getStartPoint().get(1)),
            new Point2D.Float(ascent.getEndPoint().get(0), ascent.getEndPoint().get(1)),
            new Point2D.Float(descent.getEndPoint().get(0), descent.getEndPoint().get(1)),
            new Point2D.Float(descent.getStartPoint().get(0), descent.getStartPoint().get(1)),
    };

    for (Rectangle rectangle : rectangles)
    {
        boolean glyphInRectangle = true;
        for (Point2D point2d : glyphRect)
        {
            glyphInRectangle &= rectangle.getLeft() <= point2d.getX();
            glyphInRectangle &= point2d.getX() <= rectangle.getRight();
            glyphInRectangle &= rectangle.getBottom() <= point2d.getY();
            glyphInRectangle &= point2d.getY() <= rectangle.getTop();
        }
        if (glyphInRectangle)
            return false;
    }

    return true;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:32,代碼來源:StrictPdfCleanUpRegionFilter.java

示例7: printPage3

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
private void printPage3(Document document, PdfContentByte canvas) throws DocumentException {
    int cols = 3;
    int rows = 15;

    PdfPTable table = new PdfPTable(cols);
    for (int row = 0; row < rows; row++) {
        for (int col = 0; col < cols; col++) {
            table.addCell(new Phrase("Cell " + row + ", " + col));
        }
    }
    table.setSpacingBefore(5);

    Rectangle docBounds = document.getPageSize();
    Rectangle upper = new Rectangle(docBounds.getLeft(20), docBounds.getTop(20) - 200, docBounds.getRight(20), docBounds.getTop(20));
    upper.setBackgroundColor(new BaseColor(23, 142, 255, 20));
    Rectangle lower = new Rectangle(docBounds.getLeft(20), docBounds.getBottom(20), docBounds.getRight(20), docBounds.getBottom(20) + 600);
    lower.setBackgroundColor(new BaseColor(255, 142, 23, 20));
    Rectangle[] rectangles = new Rectangle[] { upper, lower };

    for (Rectangle bounds : rectangles)
    {
        bounds.setBorder(Rectangle.BOX);
        bounds.setBorderColor(BaseColor.BLACK);
        bounds.setBorderWidth(1);

        canvas.rectangle(bounds);
    }

    rectangles = drawKeepTogether(new Paragraph("This table should keep together!"), canvas, rectangles);
    rectangles = drawKeepTogether(table, canvas, rectangles);
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:32,代碼來源:TableKeepTogether.java

示例8: splitIntoHalfPages

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
/**
 * This methods creates a copy of the source document containing each page twice,
 * once with the cropbox limited to the left half page, once to the right one.
 */
void splitIntoHalfPages(InputStream source, File target) throws IOException, DocumentException
{
    final PdfReader reader = new PdfReader(source);
    
    try (   OutputStream targetStream = new FileOutputStream(target)    )
    {
        Document document = new Document();
        PdfCopy copy = new PdfCopy(document, targetStream);
        document.open();

        for (int page = 1; page <= reader.getNumberOfPages(); page++)
        {
            PdfDictionary pageN = reader.getPageN(page);
            Rectangle cropBox = reader.getCropBox(page);
            PdfArray leftBox = new PdfArray(new float[]{cropBox.getLeft(), cropBox.getBottom(), (cropBox.getLeft() + cropBox.getRight()) / 2.0f, cropBox.getTop()});
            PdfArray rightBox = new PdfArray(new float[]{(cropBox.getLeft() + cropBox.getRight()) / 2.0f, cropBox.getBottom(), cropBox.getRight(), cropBox.getTop()});

            PdfImportedPage importedPage = copy.getImportedPage(reader, page);
            pageN.put(PdfName.CROPBOX, leftBox);
            copy.addPage(importedPage);
            pageN.put(PdfName.CROPBOX, rightBox);
            copy.addPage(importedPage);
        }
        
        document.close();
    }
    finally
    {
        reader.close();
    }
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:36,代碼來源:SplitIntoHalfPages.java

示例9: centerIn

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
Rectangle centerIn(Rectangle source, int rotation, float width, float height)
{
    if (rotation % 180 != 0)
    {
        float temp = height;
        height = width;
        width = temp;
    }

    float halfWidthToRemove = (source.getWidth() - width) / 2.0f;
    float halfHeightToRemove = (source.getHeight() - height) / 2.0f;
    return new Rectangle(source.getLeft(halfWidthToRemove), source.getBottom(halfHeightToRemove),
            source.getRight(halfWidthToRemove), source.getTop(halfHeightToRemove));
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:15,代碼來源:UnifiedPagesizeMerging.java

示例10: enhanceBy

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
Rectangle enhanceBy(Rectangle source, Rectangle addition)
{
    Rectangle result = new Rectangle(source);
    if (addition.getLeft() < result.getLeft())
        result.setLeft(addition.getLeft());
    if (addition.getRight() > result.getRight())
        result.setRight(addition.getRight());
    if (addition.getBottom() < result.getBottom())
        result.setBottom(addition.getBottom());
    if (addition.getTop() > result.getTop())
        result.setTop(addition.getTop());
    return result;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:14,代碼來源:UnifiedPagesizeMerging.java

示例11: find

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
public Collection<Rectangle2D> find(PdfReader reader, float minWidth, float minHeight, int page) throws IOException
{
    Rectangle cropBox = reader.getCropBox(page);
    Rectangle2D crop = new Rectangle2D.Float(cropBox.getLeft(), cropBox.getBottom(), cropBox.getWidth(), cropBox.getHeight());
    FreeSpaceFinder finder = new FreeSpaceFinder(crop, minWidth, minHeight);
    PdfReaderContentParser parser = new PdfReaderContentParser(reader);
    parser.processContent(page, finder);
    return finder.freeSpaces;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:10,代碼來源:FindFreeSpace.java

示例12: findExt

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
public Collection<Rectangle2D> findExt(PdfReader reader, float minWidth, float minHeight, int page) throws IOException
{
    Rectangle cropBox = reader.getCropBox(page);
    Rectangle2D crop = new Rectangle2D.Float(cropBox.getLeft(), cropBox.getBottom(), cropBox.getWidth(), cropBox.getHeight());
    FreeSpaceFinder finder = new FreeSpaceFinderExt(crop, minWidth, minHeight);
    PdfReaderContentParser parser = new PdfReaderContentParser(reader);
    parser.processContent(page, finder);
    return finder.freeSpaces;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:10,代碼來源:FindFreeSpace.java

示例13: getPointsOfInterest

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
Point2D[] getPointsOfInterest(Rectangle box)
{
    Point2D[] result = new Point2D[6];
    result[0] = new Point2D.Float(box.getLeft(), box.getTop());
    result[1] = new Point2D.Float(box.getRight(), box.getTop());
    result[2] = new Point2D.Float(box.getRight(), (box.getTop() + box.getBottom()) / 2.0f);
    result[3] = new Point2D.Float(box.getRight(), box.getBottom());
    result[4] = new Point2D.Float(box.getLeft(), box.getBottom());
    result[5] = new Point2D.Float(box.getLeft(), (box.getTop() + box.getBottom()) / 2.0f);
    return result;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:12,代碼來源:FindFreeSpace.java

示例14: overlaps

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
private static boolean overlaps(Rectangle rect1, Rectangle rect2) {
    if (rect1.getLeft() >= rect2.getRight() || rect1.getRight() <= rect2.getLeft() || rect1.getTop() <= rect2.getBottom() || rect1.getBottom() >= rect2.getTop())
        return false;
    return true;
}
 
開發者ID:damianofalcioni,項目名稱:Websocket-Smart-Card-Signer,代碼行數:6,代碼來源:PDFManager.java

示例15: contains

import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
private static boolean contains(Rectangle rect1, Rectangle rect2) {
    return rect1.getLeft() <= rect2.getLeft() && rect1.getRight() >= rect2.getRight() && rect1.getBottom() <= rect2.getBottom() && rect1.getTop() >= rect2.getTop();
}
 
開發者ID:damianofalcioni,項目名稱:Websocket-Smart-Card-Signer,代碼行數:4,代碼來源:PDFManager.java


注:本文中的com.itextpdf.text.Rectangle.getLeft方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。