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


Java PDPageContentStream.addRect方法代码示例

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


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

示例1: clipPage

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
void clipPage(PDDocument document, PDPage page, BoundingBox clipBox) throws IOException
{
	PDPageContentStream pageContentStream = new PDPageContentStream(document, page, true, false);
	pageContentStream.addRect(clipBox.getLowerLeftX(), clipBox.getLowerLeftY(), clipBox.getWidth(), clipBox.getHeight());
	pageContentStream.clipPath(PathIterator.WIND_NON_ZERO);
	pageContentStream.close();

	COSArray newContents = new COSArray();
	COSStreamArray contents = (COSStreamArray) page.getContents().getStream();
	newContents.add(contents.get(contents.getStreamCount()-1));
	for (int i = 0; i < contents.getStreamCount()-1; i++)
	{
		newContents.add(contents.get(i));
	}
	page.setContents(new PDStream(new COSStreamArray(newContents)));
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:17,代码来源:ClipPage.java

示例2: renderFrame

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
public static void renderFrame(PDPageContentStream contentStream, org.phoenixctms.ctsms.enumeration.Color color, float x, float y, float width, float height, Alignment align,
		float lineWidth, LineStyle lineStyle) throws IOException {
	if (contentStream != null && lineWidth > 0.0f) {
		float left = x;
		float bottom = y - height;
		if (align != null) {
			switch (align) {
				case TOP_CENTER:
					left = x - width / 2.0f;
					bottom = y - height;
					break;
				case TOP_RIGHT:
					left = x - width;
					bottom = y - height;
					break;
				case MIDDLE_LEFT:
					left = x;
					bottom = y - height / 2.0f;
					break;
				case MIDDLE_CENTER:
					left = x - width / 2.0f;
					bottom = y - height / 2.0f;
					break;
				case MIDDLE_RIGHT:
					left = x - width;
					bottom = y - height / 2.0f;
					break;
				case BOTTOM_LEFT:
					left = x;
					bottom = y;
					break;
				case BOTTOM_CENTER:
					left = x - width / 2.0f;
					bottom = y;
					break;
				case BOTTOM_RIGHT:
					left = x - width;
					bottom = y;
					break;
				default: // topleft else...
			}
		}
		contentStream.setStrokingColor(CommonUtil.convertColor(color));
		setLineDashPattern(contentStream, lineStyle);
		contentStream.setLineWidth(lineWidth);
		contentStream.addRect(left, bottom, width, height);
		contentStream.closeAndStroke();
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:50,代码来源:PDFUtil.java

示例3: drawReletivePartAndMovePosition

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
/**
    * Actually draws the (drawble) part at the
    * {@link RenderContext#getCurrentPosition()} and - depending on flag
    * <code>movePosition</code> - moves to the new Y position. Any left or
    * right margin is taken into account to calculate the position and
    * alignment.
    * 
    * @param renderContext
    *            the context providing all rendering state.
    * @param drawable
    *            the drawable to draw.
    * @param layoutHint
    *            the layout hint used to layout.
    * @param movePosition
    *            indicates if the position should be moved (vertically) after
    *            drawing.
    * @throws IOException
    *             by pdfbox
    */
   protected void drawReletivePartAndMovePosition(
    final RenderContext renderContext, Drawable drawable,
    final LayoutHint layoutHint, final boolean movePosition)
    throws IOException {
PDPageContentStream contentStream = renderContext.getContentStream();
PageFormat pageFormat = renderContext.getPageFormat();
float offsetX = 0;
if (layoutHint instanceof VerticalLayoutHint) {
    VerticalLayoutHint verticalLayoutHint = (VerticalLayoutHint) layoutHint;
    Alignment alignment = verticalLayoutHint.getAlignment();
    float horizontalExtraSpace = getTargetWidth(renderContext)
	    - drawable.getWidth();
    switch (alignment) {
    case Right:
	offsetX = horizontalExtraSpace
		- verticalLayoutHint.getMarginRight();
	break;
    case Center:
	offsetX = horizontalExtraSpace / 2f;
	break;
    default:
	offsetX = verticalLayoutHint.getMarginLeft();
	break;
    }
}

contentStream.saveGraphicsState();
contentStream.addRect(0, pageFormat.getMarginBottom(), renderContext.getPageWidth(),
	renderContext.getHeight());
CompatibilityHelper.clip(contentStream);

drawable.draw(renderContext.getPdDocument(), contentStream,
	renderContext.getCurrentPosition().add(offsetX, 0),renderContext);

contentStream.restoreGraphicsState();

if (movePosition) {
    renderContext.movePositionBy(0, -drawable.getHeight());
}
   }
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:60,代码来源:VerticalLayout.java

示例4: add

import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; //导入方法依赖的package包/类
@Override
   public void add(PDDocument pdDocument, PDPageContentStream contentStream,
           Position upperLeft, float width, float height) throws IOException {
contentStream.addRect(upperLeft.getX(), upperLeft.getY() - height,
	width, height);
   }
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:7,代码来源:Rect.java


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