/** * @see RenderListener#renderImage(ImageRenderInfo) */ public void renderImage(ImageRenderInfo renderInfo) { Matrix imageCtm = renderInfo.getImageCTM(); Vector a = new Vector(0, 0, 1).cross(imageCtm); Vector b = new Vector(1, 0, 1).cross(imageCtm); Vector c = new Vector(0, 1, 1).cross(imageCtm); Vector d = new Vector(1, 1, 1).cross(imageCtm); LineSegment bottom = new LineSegment(a, b); LineSegment top = new LineSegment(c, d); if (textRectangle == null) textRectangle = bottom.getBoundingRectange(); else textRectangle.add(bottom.getBoundingRectange()); textRectangle.add(top.getBoundingRectange()); }
@Override public void renderImage(ImageRenderInfo renderInfo) { Matrix imageMatrix = renderInfo.getImageCTM(); Vector image00 = rect00.cross(imageMatrix); Vector image01 = rect01.cross(imageMatrix); Vector image10 = rect10.cross(imageMatrix); Vector image11 = rect11.cross(imageMatrix); Rectangle2D usedSpace = new Rectangle2D.Float(image00.get(Vector.I1), image00.get(Vector.I2), 0, 0); usedSpace.add(image01.get(Vector.I1), image01.get(Vector.I2)); usedSpace.add(image10.get(Vector.I1), image10.get(Vector.I2)); usedSpace.add(image11.get(Vector.I1), image11.get(Vector.I2)); remove(usedSpace); }
public static float[] getKeyWords(String filePath) { try { PdfReader pdfReader = new PdfReader(filePath); int pageNum = pdfReader.getNumberOfPages(); PdfReaderContentParser pdfReaderContentParser = new PdfReaderContentParser(pdfReader); // 下标从1开始 for (i = 1; i <= pageNum; i++) { pdfReaderContentParser.processContent(i, new RenderListener() { public void renderText(TextRenderInfo textRenderInfo) { String text = textRenderInfo.getText(); System.out.println(i + ":" +text); if (null != text && text.contains(KEY_WORD)) { Float boundingRectange = textRenderInfo.getBaseline().getBoundingRectange(); resu = new float[3]; resu[0] = boundingRectange.x; resu[1] = boundingRectange.y; resu[2] = i; } } public void renderImage(ImageRenderInfo arg0) { } public void endTextBlock() { } public void beginTextBlock() { } }); } } catch (IOException e) { e.printStackTrace(); } return resu; }
@Override public void renderImage(ImageRenderInfo renderInfo) { Matrix ctm = renderInfo.getImageCTM(); float[] yCoords = new float[4]; for (int x=0; x < 2; x++) for (int y=0; y < 2; y++) { Vector corner = new Vector(x, y, 1).cross(ctm); yCoords[2*x+y] = corner.get(Vector.I2); } Arrays.sort(yCoords); addVerticalUseSection(yCoords[0], yCoords[3]); }
@Override public void renderImage(ImageRenderInfo info) { }
@Override public void renderImage(ImageRenderInfo renderInfo) { }
@Override public void renderImage(ImageRenderInfo arg0) { }
@Override public void renderImage(ImageRenderInfo renderInfo) { strategy.renderImage(renderInfo); }
/** * no-op method - this renderer isn't interested in image events * @see com.itextpdf.text.pdf.parser.RenderListener#renderImage(com.itextpdf.text.pdf.parser.ImageRenderInfo) * @since 5.0.1 */ public void renderImage(ImageRenderInfo renderInfo) { // do nothing }
/** * @see com.itextpdf.text.pdf.parser.RenderListener#renderImage( *com.itextpdf.text.pdf.parser.ImageRenderInfo) */ public void renderImage(ImageRenderInfo renderInfo) { }