当前位置: 首页>>代码示例>>Java>>正文


Java PDRectangle.setLowerLeftY方法代码示例

本文整理汇总了Java中org.apache.pdfbox.pdmodel.common.PDRectangle.setLowerLeftY方法的典型用法代码示例。如果您正苦于以下问题:Java PDRectangle.setLowerLeftY方法的具体用法?Java PDRectangle.setLowerLeftY怎么用?Java PDRectangle.setLowerLeftY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pdfbox.pdmodel.common.PDRectangle的用法示例。


在下文中一共展示了PDRectangle.setLowerLeftY方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addHyperlink

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
private void addHyperlink(
        final float x, final float y,
        final String hyperlink,
        final PDPage pdPage) throws IOException {

    PDAnnotationLink txtLink = new PDAnnotationLink();

    PDRectangle position = new PDRectangle();
    PDBorderStyleDictionary underline = new PDBorderStyleDictionary();
    underline.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
    txtLink.setBorderStyle(underline);

    position.setLowerLeftX(x);
    position.setLowerLeftY(y);
    position.setUpperRightX(X_MARGIN_LEFT + BOX_WIDTH);
    position.setUpperRightY(y + TEXT_LINE_HEIGHT);
    txtLink.setRectangle(position);

    PDActionURI action = new PDActionURI();
    action.setURI(hyperlink);
    txtLink.setAction(action);
    pdPage.getAnnotations().add(txtLink);
}
 
开发者ID:estatio,项目名称:estatio,代码行数:24,代码来源:PdfManipulator.java

示例2: addLink

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
private float addLink(PDDocument document, int pageNumber, float startX, float startY, PdfTextStyle textConfig) {
    PDAnnotationLink txtLink = new PDAnnotationLink();
    txtLink.setColor(textConfig.getColor());

    PDBorderStyleDictionary underline = getLinkUnderline();
    txtLink.setBorderStyle(underline);

    try {
        float textWidth = (textConfig.getFont().getStyle(textConfig.getStyle()).getStringWidth(text) / 1000) * textConfig.getFontSize();

        float startLinkY = startY + textConfig.getFontSize();
        float endLinkY = startY - underline.getWidth();

        PDRectangle position = new PDRectangle();
        position.setLowerLeftX(startX);
        position.setLowerLeftY(startLinkY);
        position.setUpperRightX(startX + textWidth);
        position.setUpperRightY(endLinkY);
        txtLink.setRectangle(position);

        PDActionURI action = new PDActionURI();
        action.setURI(link);
        txtLink.setAction(action);

        PDPage page = document.getDocumentCatalog().getPages().get(pageNumber);
        page.getAnnotations().add(txtLink);

        return endLinkY;
    } catch (IOException e) {
        LOG.warn("Could not add link: " + e.getClass() + " - " + e.getMessage());
        return startY;
    }
}
 
开发者ID:Catalysts,项目名称:cat-boot,代码行数:34,代码来源:ReportLink.java

示例3: transformToPageRotation

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
/**
    * Transform the rectangle in order to match the page rotation
    * @param rect the rectangle.
    * @param page the page.
    * @return the transformed rectangle.
    */
   public static PDRectangle transformToPageRotation(
    final PDRectangle rect, final PDPage page) {
AffineTransform transform = transformToPageRotation(page);
if (transform == null) {
    return rect;
}
float[] points = new float[] {rect.getLowerLeftX(), rect.getLowerLeftY(), rect.getUpperRightX(), rect.getUpperRightY()};
float[] rotatedPoints = new float[4]; 
transform.transform(points, 0, rotatedPoints, 0, 2);
PDRectangle rotated = new PDRectangle();
rotated.setLowerLeftX(rotatedPoints[0]);
rotated.setLowerLeftY(rotatedPoints[1]);
rotated.setUpperRightX(rotatedPoints[2]);
rotated.setUpperRightY(rotatedPoints[3]);
return rotated;
   }
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:23,代码来源:CompatibilityHelper.java

示例4: handleHyperlinkAnnotations

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
protected void handleHyperlinkAnnotations(
    AnnotatedStyledText annotatedText, DrawContext drawContext,
    Position upperLeft, float width, float height) {
Iterable<HyperlinkAnnotation> hyperlinkAnnotations = annotatedText
	.getAnnotationsOfType(HyperlinkAnnotation.class);
for (HyperlinkAnnotation hyperlinkAnnotation : hyperlinkAnnotations) {
    List<Hyperlink> links = linkMap.get(drawContext.getCurrentPage());
    if (links == null) {
	links = new ArrayList<Hyperlink>();
	linkMap.put(drawContext.getCurrentPage(), links);
    }
    PDRectangle bounds = new PDRectangle();
    bounds.setLowerLeftX(upperLeft.getX());
    bounds.setLowerLeftY(upperLeft.getY() - height);
    bounds.setUpperRightX(upperLeft.getX() + width);
    bounds.setUpperRightY(upperLeft.getY());

    links.add(new Hyperlink(bounds, annotatedText.getColor(),
	    hyperlinkAnnotation.getLinkStyle(), hyperlinkAnnotation
		    .getHyperlinkURI()));
}
   }
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:23,代码来源:HyperlinkAnnotationProcessor.java

示例5: fillBeadRectangles

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
private void fillBeadRectangles(PDPage page)
{
    beadRectangles = new ArrayList<PDRectangle>();
    for (PDThreadBead bead : page.getThreadBeads())
    {
        if (bead == null)
        {
            // can't skip, because of null entry handling in processTextPosition()
            beadRectangles.add(null);
            continue;
        }
        
        PDRectangle rect = bead.getRectangle();
        
        // bead rectangle is in PDF coordinates (y=0 is bottom),
        // glyphs are in image coordinates (y=0 is top),
        // so we must flip
        PDRectangle mediaBox = page.findMediaBox();
        float upperRightY = mediaBox.getUpperRightY() - rect.getLowerLeftY();
        float lowerLeftY = mediaBox.getUpperRightY() - rect.getUpperRightY();
        rect.setLowerLeftY(lowerLeftY);
        rect.setUpperRightY(upperRightY);
        
        // adjust for cropbox
        PDRectangle cropBox = page.findCropBox();
        if (cropBox.getLowerLeftX() != 0 || cropBox.getLowerLeftY() != 0)
        {
            rect.setLowerLeftX(rect.getLowerLeftX() - cropBox.getLowerLeftX());
            rect.setLowerLeftY(rect.getLowerLeftY() - cropBox.getLowerLeftY());
            rect.setUpperRightX(rect.getUpperRightX() - cropBox.getLowerLeftX());
            rect.setUpperRightY(rect.getUpperRightY() - cropBox.getLowerLeftY());
        }
        
        beadRectangles.add(rect);
    }
}
 
开发者ID:hemangandhi,项目名称:my-cv-site,代码行数:37,代码来源:FormattedReader.java

示例6: addLinkToPage

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void addLinkToPage(float x, float y, float width, PDFPage trgPage) throws IOException {
	  List annotations = page.getAnnotations();
         

         PDAnnotationLink txtLink = new PDAnnotationLink();
         
         PDRectangle position = new PDRectangle();
         position.setLowerLeftX(x);
         position.setLowerLeftY(y);  // down a couple of points
         position.setUpperRightX(x+width);
         position.setUpperRightY(y+10);
         txtLink.setRectangle(position);

         // add an action
         PDActionGoTo action = new PDActionGoTo();
         PDPageDestination destination = new PDPageFitDestination();
         destination.setPage(trgPage);
         action.setDestination(destination);
         txtLink.setAction(action);

         annotations.add(txtLink);
}
 
开发者ID:purbon,项目名称:pdfwriter,代码行数:24,代码来源:PDFContentPage.java

示例7: annotatedObjectDrawn

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
@Override
public void annotatedObjectDrawn(Annotated drawnObject,
	DrawContext drawContext, Position upperLeft, float width,
	float height) throws IOException {

    Iterable<HighlightAnnotation> HighlightAnnotations = drawnObject
	    .getAnnotationsOfType(HighlightAnnotation.class);

    for (HighlightAnnotation highlightAnnotation : HighlightAnnotations) {

	// use PDF text markup to implement the highlight
	PDAnnotationTextMarkup markup = new PDAnnotationTextMarkup(
		PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);

	// use the bounding box of the drawn object to position the
	// highlight
	PDRectangle bounds = new PDRectangle();
	bounds.setLowerLeftX(upperLeft.getX());
	bounds.setLowerLeftY(upperLeft.getY() - height);
	bounds.setUpperRightX(upperLeft.getX() + width);
	bounds.setUpperRightY(upperLeft.getY() + 1);
	markup.setRectangle(bounds);
	float[] quadPoints = CompatibilityHelper.toQuadPoints(bounds);
	quadPoints = CompatibilityHelper.transformToPageRotation(
		quadPoints, drawContext.getCurrentPage());
	markup.setQuadPoints(quadPoints);

	// set the highlight color if given
	if (highlightAnnotation.getColor() != null) {
	    CompatibilityHelper.setAnnotationColor(markup, highlightAnnotation.getColor());
	}

	// finally add the markup to the PDF
	drawContext.getCurrentPage().getAnnotations().add(markup);
    }
}
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:37,代码来源:CustomAnnotation.java

示例8: createRollover

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
void createRollover(PDAnnotation annotation, String filename) throws IOException, COSVisitorException
{
    PDDocument document = new PDDocument();
    PDPage page = new PDPage();
    document.addPage(page);
    List<PDAnnotation> annotations = page.getAnnotations();

    float x = 100;
    float y = 500;
    String text = "PDFBox";
    PDFont font = PDType1Font.HELVETICA_BOLD;
    float textWidth = font.getStringWidth(text) / 1000 * 18;

    PDPageContentStream contents = new PDPageContentStream(document, page);
    contents.beginText();
    contents.setFont(font, 18);
    contents.moveTextPositionByAmount(x, y);
    contents.drawString(text);
    contents.endText();
    contents.close();

    PDAppearanceDictionary appearanceDictionary = new PDAppearanceDictionary();
    PDAppearanceStream normal = createAppearanceStream(document, textWidth, font, "0.5 0.5 0.5 rg");
    PDAppearanceStream rollover = createAppearanceStream(document, textWidth, font, "1 0.7 0.5 rg");
    PDAppearanceStream down = createAppearanceStream(document, textWidth, font, "0 0 0 rg");
    appearanceDictionary.setNormalAppearance(normal);
    appearanceDictionary.setRolloverAppearance(rollover);
    appearanceDictionary.setDownAppearance(down);
    annotation.setAppearance(appearanceDictionary);

    PDRectangle position = new PDRectangle();
    position.setLowerLeftX(x);
    position.setLowerLeftY(y - 5);
    position.setUpperRightX(x + textWidth);
    position.setUpperRightY(y + 20);
    annotation.setRectangle(position);

    annotations.add(annotation);
    document.save(new File(RESULT_FOLDER, filename));
    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:42,代码来源:RolloverAnnotation.java

示例9: changeCropBox

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
private static void changeCropBox(PDDocument document, float a, float b, float c, float d)
{
    for (PDPage page : document.getPages())
    {
        PDRectangle rectangle = new PDRectangle();
        rectangle.setLowerLeftX(a);
        rectangle.setLowerLeftY(b);
        rectangle.setUpperRightX(c);
        rectangle.setUpperRightY(d);
        page.setCropBox(rectangle);

    }
}
 
开发者ID:juliusHuelsmann,项目名称:paint,代码行数:14,代码来源:PDFUtils.java

示例10: changeCropBoxes

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
private void changeCropBoxes(PDDocument document, float a, float b, float c, float d) {
    List pages = document.getDocumentCatalog().getAllPages();
    for (int i = 0; i < pages.size(); i++) {
        PDPage page = (PDPage) pages.get(i);
        PDRectangle rectangle = new PDRectangle();
        rectangle.setLowerLeftX(a);
        rectangle.setLowerLeftY(b);
        rectangle.setUpperRightX(c);
        rectangle.setUpperRightY(d);
        page.setMediaBox(rectangle);
        page.setCropBox(rectangle);

    }
}
 
开发者ID:tseho,项目名称:PdfToCbz,代码行数:15,代码来源:PdfToImages.java

示例11: toPDRectangle

import org.apache.pdfbox.pdmodel.common.PDRectangle; //导入方法依赖的package包/类
public PDRectangle toPDRectangle()
{
	PDRectangle retVal = new PDRectangle();
	retVal.setLowerLeftX(x1);
	retVal.setLowerLeftY(y1);
	retVal.setUpperRightX(x2);
	retVal.setUpperRightY(y2);
	return retVal;
}
 
开发者ID:tamirhassan,项目名称:pdfxtk,代码行数:10,代码来源:GenericSegment.java


注:本文中的org.apache.pdfbox.pdmodel.common.PDRectangle.setLowerLeftY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。