本文整理匯總了Java中com.itextpdf.text.Rectangle.getTop方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.getTop方法的具體用法?Java Rectangle.getTop怎麽用?Java Rectangle.getTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getTop方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
示例2: 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));
}
}
示例3: createSimpleCircleGraphicsPdf
import com.itextpdf.text.Rectangle; //導入方法依賴的package包/類
static byte[] createSimpleCircleGraphicsPdf(int radius, int gap, int count) throws DocumentException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();
float y = writer.getPageSize().getTop();
for (int i = 0; i < count; i++)
{
Rectangle pageSize = writer.getPageSize();
if (y <= pageSize.getBottom() + 2*radius)
{
y = pageSize.getTop();
writer.getDirectContent().fillStroke();
document.newPage();
}
writer.getDirectContent().circle(pageSize.getLeft() + pageSize.getWidth() * Math.random(), y-radius, radius);
y-= 2*radius + gap;
}
writer.getDirectContent().fillStroke();
document.close();
return baos.toByteArray();
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
示例7: 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();
}
}
示例8: 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));
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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();
}